IonicWind Software

Creative Basic => General Questions => Topic started by: 3Dpdk on March 06, 2008, 01:00:27 PM

Title: Another SYSTEM command question with a "startpath" problem.
Post by: 3Dpdk on March 06, 2008, 01:00:27 PM
I have another System command problem ...

The program I am writing attempts to run another program located in a different folder. This other program needs to know it's own startpath but when run by my program the startpath continues to point to my program's folder.

Is there a way to set the startpath in Windows XP to the new folder before my program ends?

I'm pretty sure it can be done because Paul has as a download utility, a file manager that does this very thing.

Any help would be greatly appriciated from anyone who may know how to do this or knows that it CAN'T be done.

Thanks
Title: Re: Another SYSTEM command question with a "startpath" problem.
Post by: GWS on March 18, 2008, 05:20:34 AM
Hi,

I'm not sure I fully understand your question, but from within CB you can use the System command to change directory, or you can use this method:

Put this declare line near the start of your program. ('path$' can be any name you like)...

declare "kernel32",SetCurrentDirectoryA(path$:string)

Then use when needed to set your path. ("C:\" can be any path in a literal string or use a string variable)...

SetCurrentDirectoryA("C:\")

In the above example, when you access the drive then "C:\" will be the current path just like CD in DOS.

I don't know if this helps,  :)

Graham

Title: Re: Another SYSTEM command question with a "startpath" problem.
Post by: 3Dpdk on March 18, 2008, 05:29:29 AM
Thank you Graham.

At first glance I believe this is exactly what I need, and a very simple solution at that!

The program being run from my program was looking in my folder instead of it's own for it's own ini files. This appears that I can set the path to the other program's folder before my "System" command to run the exe. The system command by itself didn't seem to work properly.

Thanks for your response, this puts the polish on my program I was looking for.

Paul