Jump to content

Calling the CreateEventA windows function


Recommended Posts

I'm not sure the details of how the CINs work as far as setting up the function call stack, but you're node is not set up properly, is it possible the stack isn't being properly defined leading to undefined behavior?

lpEventAttributes - Long pointer (32 bit) to a structure, in all likelyhood should be a NULL (0) U32 value or a LV call. You're passing a null string, I'm not sure if LV will simply pass a null pointer which would work, or a pointer to a null string, at which point it's anyone's guess as two what happens. In either case, the sturct is prototyped as {DWORD, LPVOID, BOOL}, so a string pointer will in all likely hood cause all hell to break loose.

bManualReset - A BOOL is simply typedefed as a U32 in the C/C++ land, the use of a U8 might not work here.

bInitialState - Ditto

lpName - Seems right, long pointer to a string.

You're right though, a return value of 0 (NULL) means the function did not work.

Edit: A call to GetLastError might also help figure out what went wrong.

Link to comment

QUOTE (MJE @ Nov 8 2008, 10:24 AM)

I'm not sure the details of how the CINs work as far as setting up the function call stack, but you're node is not set up properly, is it possible the stack isn't being properly defined leading to undefined behavior?

lpEventAttributes - Long pointer (32 bit) to a structure, in all likelyhood should be a NULL (0) U32 value or a LV call. You're passing a null string, I'm not sure if LV will simply pass a null pointer which would work, or a pointer to a null string, at which point it's anyone's guess as two what happens. In either case, the sturct is prototyped as {DWORD, LPVOID, BOOL}, so a string pointer will in all likely hood cause all hell to break loose.

bManualReset - A BOOL is simply typedefed as a U32 in the C/C++ land, the use of a U8 might not work here.

bInitialState - Ditto

lpName - Seems right, long pointer to a string.

You're right though, a return value of 0 (NULL) means the function did not work.

Edit: A call to http://msdn.microsoft.com/en-us/library/ms679360%28VS.85%29.aspx' rel='nofollow' target="_blank">GetLastError might also help figure out what went wrong.

MJE's recommendations are all valid. The biggest trouble will be probably the lpEventAttribute structure. This should be either a NULL pointer or a valid security attribute structure. Since you are not likley going to create child processes of your LabVIEW process a NULL pointer will be fine so go with that and configure this parameter as an UINT32 (or if you use LabVIEW 8.5 or better use the new Pointer type, which will take care of adapting to 64 Bit pointers once LabVIEW for Windows 64 bit will become available) and assign it a value of 0.

Also the two Boolean variables might be a problem too although I wouldn't expect them to cause the function to fail, just do unexpected things. In Windows 32 Bit every parameter is in fact passed as 32 Bit value on the stack but if you declare it as 8Bit it's entirely up to LabVIEW if it extends that parameter to 32 Bit before pushing it on the stack or if it just fills in the 8 Bits leaving the other 24 Bits at whatever random value they might be. This would mean that whatever you do pass in as Boolean value it is very unlikely that the function will ever see anything else but non-nul (or TRUE for that matter).

Rolf Kalbermatter

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.