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.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

What is the exectution path for a sequence?

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.

0 Kudos
Message 1 of 5
(4,556 Views)

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).

0 Kudos
Message 2 of 5
(4,538 Views)

what function are you using to get the directory?  Are passing anything to your DLL?

 

Regards,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 3 of 5
(4,508 Views)

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.

0 Kudos
Message 4 of 5
(4,500 Views)

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

Message 5 of 5
(4,493 Views)