02-07-2014 10:23 AM
I've a sequence that call a DLL. In this DLL, a function collects the current directory and 1 get the Teststand cfg directory, instead of the sequence directory.
Where is the setting to change this behavior and allow my existing DLL to catch the right information?
PS: I use Teststand 2013 with a sequence from Teststand 3.1 where it was OK.
02-08-2014 09:33 AM
more details:
I start sequence, call a DLL function where I display the current dir: sometimes I get a c:\Program Files directory, sometimes Application\TSConfig directory...
I would just like to get the Application (where is located the sequence file).
02-08-2014 11:14 PM
what function are you using to get the directory? Are passing anything to your DLL?
Regards,
02-09-2014 05:21 AM
Now, I think issue may be in more in Labwindows/CVI used to create the DLL.
I use GetDir() fonction but depending on the execution (way to load the sequence?), result changes from c:\Users\Public\National InstrumentI\TestStand 2013 this morning to directory where the seq is yestarday afternoon.
02-09-2014 11:38 AM - edited 02-09-2014 11:40 AM
You should generally not be relying on the current working directory:
See the following:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa364934%28v=vs.85%29.aspx
From the article above: "Multithreaded applications and shared library code should not use the GetCurrentDirectory function and should avoid using relative path names."
If you want to find a file in a directory relative to your dll, you should use GetModuleFileName() (That's a Win32 API, there might be a CVI equivalent) instead (passing the HINSTANCE of your dll that you can get in dllmain) which will get the full path to your dll and then get the directory from that and combine it with the name of the file to build an absolute path to the file you are looking for.
Another alternative is to use the TestStand directory resolution algorithm by calling FindFile in a TestStand expression (and perhaps passing the result into your code module), or directly calling the Engine.FindFile() API.
Hope this helps,
-Doug