Can I Import "CreateEvent" into Windows CE.NET?
-
Greetings: I am trying to write a PDA program that supports a USB Host port. I am using Visual Studio 2003, C# with some imported Win32 DLL's. The driver for the USB port was provided by FTDI and appears to be installed and working very well. There is just one detail: There is one procedure in the USB DLL that requires an "event" handle that has been created and non-signaled. I am talking about the kind of event that you create with the Win32 API function "CreateEvent". The idea is that the procedure stores the event handle internally and when incoming characters are available, it will signal the event so that your read-data thread can wake up and process the new data. I have imported a few procedures from the Kernel32.DLL successfully but "CreateEvent" is not working. I have consulted the WEB site "P-Invoke.NET" which provides DllImport proper syntax for every conceivable procedure in a variety of DLL's. But whenever I make a call to "CreateEvent", I get the "MissingMethodException". So I have a few questions: 1. Does Windows CE support "CreateEvent"? 2. If not, how can I create a read-data thread that sleeps until characters are available, especially since the USB Win32 driver uses a Win32 DLL to signal? 3. Is there a repository of information anywhere where I can quickly look up what Win32 API functions are available under Windows CE? I have checked the MSDN "Platform SDK: DLLs, Processes, and Threads" document. It does NOT say that it IS supported under Windows CE but it does NOT say that it isn't either. Finally, I tried using a .NET AutoResetEvent object. It has one property "Handle" and the documentation refers to this as "the native operating system handle". I thought that perhaps that this was in fact the event handle ultimately created by "CreateEvent". However, when I passed this to the USB DLL, it did not signal as expected when characters came in (I am absolutely certain that characters were received). Have I misunderstood or misused this object? Thanks in advance to anybody who responds. Mark
-
Greetings: I am trying to write a PDA program that supports a USB Host port. I am using Visual Studio 2003, C# with some imported Win32 DLL's. The driver for the USB port was provided by FTDI and appears to be installed and working very well. There is just one detail: There is one procedure in the USB DLL that requires an "event" handle that has been created and non-signaled. I am talking about the kind of event that you create with the Win32 API function "CreateEvent". The idea is that the procedure stores the event handle internally and when incoming characters are available, it will signal the event so that your read-data thread can wake up and process the new data. I have imported a few procedures from the Kernel32.DLL successfully but "CreateEvent" is not working. I have consulted the WEB site "P-Invoke.NET" which provides DllImport proper syntax for every conceivable procedure in a variety of DLL's. But whenever I make a call to "CreateEvent", I get the "MissingMethodException". So I have a few questions: 1. Does Windows CE support "CreateEvent"? 2. If not, how can I create a read-data thread that sleeps until characters are available, especially since the USB Win32 driver uses a Win32 DLL to signal? 3. Is there a repository of information anywhere where I can quickly look up what Win32 API functions are available under Windows CE? I have checked the MSDN "Platform SDK: DLLs, Processes, and Threads" document. It does NOT say that it IS supported under Windows CE but it does NOT say that it isn't either. Finally, I tried using a .NET AutoResetEvent object. It has one property "Handle" and the documentation refers to this as "the native operating system handle". I thought that perhaps that this was in fact the event handle ultimately created by "CreateEvent". However, when I passed this to the USB DLL, it did not signal as expected when characters came in (I am absolutely certain that characters were received). Have I misunderstood or misused this object? Thanks in advance to anybody who responds. Mark
Hi, 1: Probably yes, I use it all the time, although from C++ and on the PPC2000, 2002, WM2003 & 2005 platforms. It's highly unlikely that your OEM pulled that function from their build of Windows CE if you're using a custom build, but ofcourse possible. 3: You should get a helpfile (.chm) for the SDK if you're targeting PPC or WM. I'm still stuck with EVC3, so I cant help you with where it ends up when using VS2003. Last question: .Net is not my thing and its hard to know whats wrong without seeing some code, but perhaps you should try writing a testprogram using that class? ie a thread that does the .Net equivalent of:
DWORD WINAPI thread(void* lp)
{
while (true)
{
WaitForSingleObject(event, INFINITE);
MessageBox(0, L"event signaled", L"thread", 0);
}
return 0;
}And then you can add a button that sigals the event when pressed. --- "Man will never be free until the last king is strangled with the entrails of the last priest". -- Denis Diderot