LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why does Labview crash when using DLL to retrieve desktop directory?

In Labview 7.0 I run this VI and it occasionally will crash labview upon closing it. The error is "Labview 7.0 Development System has encountered a problem and needs to close. We are sorry for the inconvenience."

The error signature is:
AppName: labview.exe AppVer: 7.0.0.4000 ModName: labview.exe
ModVer: 7.0.0.4000 Offset: 00801e0e

What do you think???
Download All
0 Kudos
Message 1 of 8
(3,480 Views)
You are almost there. LabVIEW can not allocate string buffer for you and so you have to pass a string buffer large enough to hold the path to your desktop folder.
I modified the VI to where i pass 1024 character buffer to LabVIEW to fill it with the data and its all happy now.
See attached VI.

A Rafiq
Message 2 of 8
(3,480 Views)
Attached VI is even simpler.

A Rafiq
0 Kudos
Message 3 of 8
(3,480 Views)
This was, indeed, the solution. Thanks so much for taking the time. I must say I could not find this preallocation concept in the labview documentation, but perhaps they assume a more experienced programmer would be reading it.
0 Kudos
Message 4 of 8
(3,480 Views)
This is definitely a more efficient function for what I need. I thought it was curious that you are specifying a virtual folder (0x0000) for the nFolder parameter (I'm aware you are combining it with the "force creation" flag (0x8000)). The documentation I found on the fuction stated: "If a virtual folder is specified, this function will fail.".
0 Kudos
Message 5 of 8
(3,480 Views)
Page 2-35 of "Using External Code in LabVIEW" manual says

"For arrays or strings of data, always pass a buffer or array that is large enough to hold any results that the function places in the buffer..."

Regards,
A Rafiq
0 Kudos
Message 6 of 8
(3,480 Views)
A Rafiq wrote:

> Attached VI is even simpler.
>
> A Rafiq

To be safe you should make the buffer 260 chars long. This is MAX_PATH
in WinAPI and all path buffers to ANSI WinAPI functions are supposed to
to be at least MAX_PATH long.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 7 of 8
(3,480 Views)
AKlijn wrote:

> This was, indeed, the solution. Thanks so much for taking the time.
> I must say I could not find this preallocation concept in the labview
> documentation, but perhaps they assume a more experienced programmer
> would be reading it.

As far as I remember it is mentioned in the tutorial. However this is a
very basic C programming concept, that the caller has to allocate and
deallocate buffers passed to functions. This is because there are
basically a myriad of ways to allocate memory and if the allocation and
deallocation is not done by the same entity you have to exactly specify
which memory pool has to be used. Windows itself has about three or four
different memory management libraries and most C runtime libraries add
th
eir own again, although the Microsoft Visual C runtime library does
redirect its malloc() calls to one of the WinAPI memory management
calls. But Borland runtimes typically have their own meory management
library and if a DLL created in Borland C or Delphi would allocate
memory and you would try to deallocate it in a Visual C application you
would get very bad crashes.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 8 of 8
(3,480 Views)