I am in Windows 7 x64, and trying to use the same Event object between 2 processes, one is an vb application, and the other is a C++ application, but seems the event created in one process can't be recognized in another one:
VB
Option Explicit
Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
Private Declare Function OpenEvent Lib "Kernel32" Alias "OpenEventW" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, lpName As String) As Long
Const EVENT_ALL_ACCESS = &H1F0003
Sub Testing()
Dim hCallEvent As Long
hCallEvent = OpenEvent(EVENT_ALL_ACCESS, 0, "GUID_Call_Event")
End Sub
Private Sub Form_Load()
Call Testing
End Sub
C++
int _tmain(int argc, _TCHAR* argv[])
{
HANDLE hEvent = ::CreateEvent(NULL, FALSE, FALSE, _T("GUID_Call_Event"));
DWORD dwError = ::GetLastError();
return 0;
}
Now if I start the C++ application to have the event created, and then start the vb application to get that event, it just failed with error message: "The system cannot find the file specified."
Notice:
- It failed both with VB and VBA when interact with a C++ process, but succeeded between 2 C++ processes
- Event created in VB could not be identified in a C++ process either.
Do you have any idea on this?