Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Default directory names 2

Status
Not open for further replies.

BorlandDave

Programmer
Jun 13, 2005
86
0
0
GB
I am currently developing some software which is to be used internationally. I therefore need to be a bit clever with where my program reads/writes to files because locations such as "C:\Program Files" may not exist on foriegn systems. I have done a bit of research but am still a bit unclear on a couple of things. I think I can get to "C:\Program Files\.." and C:\Windows\.. by using %ProgramFilesDir%\.. and %WinDir%\..

Are there any more of these shortcuts?

Also, how do I specify the root of the current drive. My program could be installed on any drive letter, so how do I know which one?

Cheers for any help.
 
Check this site out:

These are actually enviroment variables.For example, SYSTEMDRIVE would return "C:" if the system is installed on C. The same for WINDIR.For seeing the operating system see the variable OS(Microsoft family). Unix also has these variables...see
In UNIX just type "echo $OSTYPE", to get to the root try "cd /".

I'm not quite sure how to find the exact number of partitions and their names, but their must be a way to try the command "cd f:" and not show the error to the user, but I forgot how. Hope this helps you.
 
Thanks for the help! I am using Windows XP.

What happens if there is a multi-partition system with windows installed on C: and my program installed on D: In this case I'd want to be able to somehow specify D: as a root directory to write files to, but wouldn't SYSTEMDRIVE return C: instead?
 
I am not quite sure if I understand the question. Well if you create a setup for your program, when the user installs the program you already know the partition where he installed it, since he specified the "install path". I haven't yet found how to query windows to tell you the number of partitions and their names. I'm going to look in to it. Again, tell me how you want the user to use your program, since the most important thing is to make your changes without the user realising.
 
You can get a list of all environment variables with the shell command "set". Your programs can retrieve them using the function "getenv".
 
Thanks again for the help.

First of all, am I correct in thinking paths such as "C:\Program Files" are different in different language versions of Windows? I just installed my prog on a Turkish laptop and although lots of things were in Turkish, like most of the start menu, the Program Files path was still in English.

ctoma2005, I'm not very good at explaining things clearly but I'll expand a bit on my problem. Say for instance I have a multi-module program connected through COM interfaces installed in:

"..\MyProg\FirstModule"
"..\MyProg\SecondModule"
"..\MyProg\ThirdModule"
etc.

I want to store the path "..\MyProg" as a default-directory string in each module. How can I do this?
 
To me this is one of the things you use the registry to do.

Make an entry in the registry when installing and later read out that entry, then you got the datas for that PC.

Totte
Keep making it perfect and it will end up broken.
 
Ahh, that sounds like a good idea! I'll have to try and work out how to do it.

Thanks for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top