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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting program files directory

Status
Not open for further replies.

Skute

Programmer
Jul 21, 2003
272
GB
Hi,

how can i get the program files directory of a computer? i didnt really want to hard code c:\program files as it may be on a d:\ drive or it might be called something different.

i know of GetWindowsDirectory() to get the win dir, but how can i get the program files dir?

Thanks
 
You can use CFileFind class function FindFile recursievely in your drives to find it .There is no other way in my knowledge
Sathyan
 
Or you can do it by reading the registry
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion
Look for the value of value name ProgramFilesDir .
Ucan use Apis for opening and reading form registries
Regards
Sathyan
 
use GetWindowsDirectory or GetSystemDirectory, read first letter to get the system disk and add :\Program Files

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Sathy is right...

You should always use local computer environment variables to find important directories.

Rocco is the BOY!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top