0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

複数ユーザで同じセマフォを使う

Posted at

// 別ユーザでカーネルオブジェクトにアクセスするとアクセスに失敗する。
// アクセス制限を default 設定(NULL)からFULLACCESSに(DACLを設定しない設定)に変更
// http://msdn.microsoft.com/en-us/library/aa379286(VS.85).aspx
SECURITY_DESCRIPTOR secDesc;
SECURITY_ATTRIBUTES secAttr;

// ユーザ制限を設けない設定
InitializeSecurityDescriptor (&secDesc, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(&secDesc, true, 0, false);
secAttr.nLength = sizeof (SECURITY_ATTRIBUTES);
secAttr.bInheritHandle = FALSE;
secAttr.lpSecurityDescriptor = &secDesc;

// 1プロセスのみ許可
CSemaphore semaphore(1, 1, "Global\TestSemaphore", &secAttr);

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?