10-27-2015 08:27 AM
If a crash is happening, it is probably happening for a reason and I'd suggest trying to figure out why and fixing it. That being said the simple solution (because you are just exiting) might be to just task kill the application, once you are sure all hardware and file references are closed. Of course having a crash might indicate that you aren't actually closing all references so that might be something to look into.
I think this link describes a way of taskkilling:
https://decibel.ni.com/content/docs/DOC-28012
and here is a discussion on LAVA about why you probably shouldn't need this:
https://lavag.org/topic/16737-application-task-kill-on-exit/
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
10-27-2015 08:48 AM
It's a reference specific to the setparent function in user32.dll. FP.nativewindow is being used to grab the WND handles which are integers in labview. Do they need to be closed inside user32.dll? If so, how do I do so since they are integers in labview?
10-27-2015 09:17 AM
In all the custom Windows functions I've used that deal with the pointer HWND I've never had to do anything with closing it in LabVIEW. I assumed it was just a number referencing a place in memory, and that number would point to a non valid HWND when the window went away. I suspect your problem isn't with not closing the HWND reference. You can write a simplified VI that uses this and I suspect you wont have a crash error on exit.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
10-27-2015 09:29 AM - edited 10-27-2015 09:34 AM
If you do a FindWindow() call the returned HWND is not refcounted at all but simply returns the handle. Same about reading the FP.NativeWindow property. Therefore you should not attempt to close that HWND yourself but it will rather be closed by whoever created the window in the first place.
However you will notice that the FP.NAtiveWindow property is an uInt64 value. That should not let you fall into the trap of defining the HWNDs to SetParent() function as an unsigned 64 bit integer. On LabVIEW for 32 Bit that certainly will mess up your stack. But defining it as 32 bit integer is equally wrong if you ever intend to run the VI in LabVIEW 64 bit. The correct configuration here is a pointer sized integer which will take care to adapt to the bitness of the current LabVIEW version.
Now another thing you should be careful is that if you have set the parent of a Window you should also take care of unparenting the child window before you destroy the parent. This happens by calling SetParent() again with a NULL HWND for the hParent value. Otherwise Windows will attempt to pass events up to the now inexistent parent window and that can explain some of your crashes.
And last but not least you may have to do some extra work when parenting and unparenting a child window. The documentation to SetParent() on MSDN states specifically that you should also adjust the WS_CHILD and WS_POPUP windows style flags when parenting and unparenting a window, since Windows doesn't to that itself automatically for compatibility reasons, but these flags do have an effect in how windows events are handled for parented child windows.
10-27-2015 11:14 AM
Should it be a signed or unsigned pointer sized integer?
10-27-2015 11:26 AM - edited 10-27-2015 11:26 AM
Use whatever signedness is returned by FP.NativeWindow. It shouldn't really matter in practical use but avoids a coercion dot, which is always nice to do.
10-27-2015 11:27 AM
On the labview side, do I use 0 for null?
10-27-2015 11:39 AM - edited 10-27-2015 11:40 AM
Didn't fix the problem. Does this mean anything?
#### |
#Date: Tue, Oct 27, 2015 12:34:19 PM |
#OSName: Windows 7 Enterprise Service Pack 1 |
#OSVers: 6.1 |
#OSBuild: 7601 |
#AppName: |
#Version: 14.0 32-bit |
#AppKind: AppLib |
#AppModDate: 0/27/2015 16:32 GMT |
#LabVIEW Base Address: 0x30000000 |
InitExecSystem() call to GetCurrProcessNumProcessors() reports: 8 processors |
InitExecSystem() call to GetNumProcessors() reports: 8 processors |
InitExecSystem() will use: 8 processors |
starting LabVIEW Execution System 2 Thread 0 , capacity: 24 at [3528808460.77837470, (12:34:20.778374672 2015:10:27)] |
starting LabVIEW Execution System 2 Thread 1 , capacity: 24 at [3528808460.77837470, (12:34:20.778374672 2015:10:27)] |
starting LabVIEW Execution System 2 Thread 2 , capacity: 24 at [3528808460.77837470, (12:34:20.778374672 2015:10:27)] |
starting LabVIEW Execution System 2 Thread 3 , capacity: 24 at [3528808460.77837470, (12:34:20.778374672 2015:10:27)] |
starting LabVIEW Execution System 2 Thread 4 , capacity: 24 at [3528808460.77837470, (12:34:20.778374672 2015:10:27)] |
starting LabVIEW Execution System 2 Thread 5 , capacity: 24 at [3528808460.77837470, (12:34:20.778374672 2015:10:27)] |
starting LabVIEW Execution System 2 Thread 6 , capacity: 24 at [3528808460.77837470, (12:34:20.778374672 2015:10:27)] |
starting LabVIEW Execution System 2 Thread 7 , capacity: 24 at [3528808460.77837470, (12:34:20.778374672 2015:10:27)] |
starting LabVIEW Execution System 4 Thread 0 , capacity: 24 at [3528808460.80037590, (12:34:20.800375939 2015:10:27)] |
starting LabVIEW Execution System 4 Thread 1 , capacity: 24 at [3528808460.80037590, (12:34:20.800375939 2015:10:27)] |
starting LabVIEW Execution System 4 Thread 2 , capacity: 24 at [3528808460.80037590, (12:34:20.800375939 2015:10:27)] |
starting LabVIEW Execution System 4 Thread 3 , capacity: 24 at [3528808460.80037590, (12:34:20.800375939 2015:10:27)] |
starting LabVIEW Execution System 4 Thread 4 , capacity: 24 at [3528808460.80037590, (12:34:20.800375939 2015:10:27)] |
starting LabVIEW Execution System 4 Thread 5 , capacity: 24 at [3528808460.80037590, (12:34:20.800375939 2015:10:27)] |
starting LabVIEW Execution System 4 Thread 6 , capacity: 24 at [3528808460.80037590, (12:34:20.800375939 2015:10:27)] |
starting LabVIEW Execution System 4 Thread 7 , capacity: 24 at [3528808460.80037590, (12:34:20.800375939 2015:10:27)] |
<DEBUG_OUTPUT> |
35:21.4 |
Crash 0x00000000: Crash caught by NIER |
File Unknown(0) : Crash 0x00000000: Crash caught by NIER |
minidump id: 31a12764-f49f-4cac-88ec-af578c5a6c9a |
ExceptionCode: 0xC0000005 |
</DEBUG_OUTPUT> |
0x100011AB - nierInterface <unknown> + 0 |
0x10005E86 - nierInterface <unknown> + 0 |
0x1000620C - nierInterface <unknown> + 0 |
0x0ED6E6B7 - cei_install <unknown> + 0 |
0x77A47782 - ntdll <unknown> + 0 |
0x77A334BB - ntdll <unknown> + 0 |
0x00000000 - <unknown> <unknown> + 0 |