From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve labview dll path from inside the dll

Hi,

 

I'm currently trying to port over to a Labview dll a C function that I used on another project which allows me to retrieve the full path of the dll that function has been called from. This function uses GetModuleFilename from Kernell32.dll.

In addition to this the dll handle is copied to a global variable in dllMain (in the C dll), and this handle is passed in to GetModuleFilename.

In labview I can call GetModuleFilenameA using Call Library Function Node succesfully, and pass a zero as the handle, which will give me the path of the executable which is calling the dll. However how can I access the dll handle within Labview, in order to get the full path of the dll?

 

Cheers,

redfrank

 

0 Kudos
Message 1 of 3
(2,460 Views)

Well since you write the DLL you probably know the name of the DLL and therefore GetModuleHandle(<your DLL name>); should return a handle to your own DLL and then you can use that to retrieve the path. Alternatively you can pass the magic constant HINST_THISCOMPONENT to GetModuleFileName(). I believe to remember that this magic could have some trouble under certain circumstances so the module name would be probably safer, although not generic.

Rolf Kalbermatter
My Blog
Message 2 of 3
(2,438 Views)

Excellent - that worked (using the GetModuleHandle call).

 

Thanks a lot!

0 Kudos
Message 3 of 3
(2,403 Views)