开发者

Can't read global mutex created with Createmutex

开发者 https://www.devze.com 2022-12-09 12:51 出处:网络
I created a mutex in one app; the code is: HANDLE global_mutex = CreateMutex(NULL, FALSE, \"mcdonalds\");

I created a mutex in one app; the code is:

HANDLE global_mutex = CreateMutex(NULL, FALSE, "mcdonalds");
if(global_mutex)
{
    wxLogMessage("created successfully.");
}
else
{
    wxLogFatalError("Unable to create the 开发者_开发问答mutex");
}

then I read it from my other program

Public Declare Function GetLastError Lib "kernel32" () As Long

Public Declare Function OpenMutex Lib "Kernel32" _
Alias "OpenMutex" (ByRef dwDesiredAccess As Integer, ByVal bInheritHandle As Boolean, _
ByVal lpName As String) As Long




Dim SingleAppHandle As Long
Dim MutexName As String
MutexName = "mcdonalds"
    SingleAppHandle = OpenMutex(0, 0, MutexName)
If SingleAppHandle = 0 Then
    Dim error_number
    error_number = GetLastError()
    MessageBox error_number
Else
    [DO STUFF]
End If

However, I keep getting openmutex returning NULL and lasterror set to 1314 which is ERROR_PRIVILEGE_NOT_HELD

Running on Windows XP Pro sp3


Try with the first parameter set to MUTEX_ALL_ACCESS (&H1F0001)

Has been too long since I did it myself, but I found that example on the net

0

精彩评论

暂无评论...
验证码 换一张
取 消