Current working directory (aGetDirCurrent) change with Ateasy code

Tymoteusz C.
Kwidzyn, Pomorskie

Nov 25, 2022
5 Posts

0  |  0  

Re: Current working directory (aGetDirCurrent) change with Ateasy code

Hi,

I'm currently working with DLL driver for TRI machines that use "Current working directory" and  during initialization procedure changes it to:
"c:\etr5001TSII\"

With that path - all it's working OK

Unfortunately we have to add to this project ATeasy made DLL driver and when I run any of it's procedures - "Current working directory" changes to project path:
"d:\Project1\"

and with that change - the TRI driver give me error message that the path to some DLLs are not correct

My question:
Is it possible to change "Current working directory" with ateasy code? So that after using Ateasy made DLL I would change it back to "c:\etr5001TSII\" so the rest of the code would work ok?

Solution Available
DrATEasy (Ron Y.)
Mission Viejo, CA

Nov 27, 2022
369 Posts

1  |  0  

Re: Current working directory (aGetDirCurrent) change with Ateasy code

Define a DLL library that uses kernel32.dll and a function called SetCurrentDirectoryA(sDirectory: bool). See https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setcurrentdirectory.

Call it before calling the initialize function.

Ron

Tymoteusz C.
Kwidzyn, Pomorskie

Dec 2, 2022
5 Posts

0  |  0  

Re: Current working directory (aGetDirCurrent) change with Ateasy code

Thank you - it worked!

I've added .NET driver: mscorlib and in code the first line was taking Current Directory
sCurrDir = mscorlib.Directory.GetCurrentDirectory()

and at the end of all code in procedure/event it was setting the directory to the first one:
mscorlib.Directory.SetCurrentDirectory(sCurrDir)



Please Note
You need to have a M@GIC account to participate in the Forums.
Not yet registered on our website? Click here to register today!

All content, information and opinions presented on the Marvin Test Solutions User Forums are those of the authors of the posts and messages and not Marvin Test Solutions'. All attachments and files are downloaded at your own risk. [Read More]