VB 删除一个信号
如果某个信号存在就删除该信号怎么弄?
- VB code
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As LongPrivate Declare Function CreateSemaphore Lib "kernel32" Alias "CreateSemaphoreA" (lpSemaphoreAttributes As SECURITY_ATTRIBUTES, ByVal lInitialCount As Long, ByVal lMaximumCount As Long, ByVal lpName As String) As LongPrivate Type SECURITY_ATTRIBUTES nLength As Long lpSecurityDescriptor As Long bInheritHandle As LongEnd TypePublic Function RunOnSetup(ByVal ExeName As String) As Long Dim MdiMenuHwnd As Long Dim hMenu As Long Dim Semaphore As String, Sema As Long, Security As SECURITY_ATTRIBUTES Dim PrevSemaphore As Long, Turn As Long Security.bInheritHandle = True Security.lpSecurityDescriptor = 0 Security.nLength = Len(Security) Semaphore = ExeName Sema = CreateSemaphore(Security, 1, 1, Semaphore) Turn = WaitForSingleObject(Sema, 0) RunOnSetup = TurnEnd FunctionIf RunOnSetup("Update") <> 0 Then '删除该信号End If
[解决办法]
这个不是那个啥么?好像书上有的,不过我记不得哪本书了。
[解决办法]
ReleaseSemaphore
[解决办法]
lpSemaphoreAttributes 可以直接传Byval 0,不需要Security.bInheritHandle = True