07-11-2014 05:28 AM
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
07-11-2014 08:55 AM - edited 07-11-2014 08:56 AM
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.
07-14-2014 06:16 AM
Excellent - that worked (using the GetModuleHandle call).
Thanks a lot!