Click here to Skip to main content
15,899,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am using
C++
SHGetSpecialFolderPath(0, path, CSIDL_PROGRAM_FILES, FALSE);

for get path Program files directory. it works good if I have on Program Files folder in my PC only.
For examples I have two "Program Files" folder is my PC, one in drive C & another in Drive D. When run code it only find "Program Files" folder in drive C that installed my windows and not finds path for "Program files" that located in drive D.
My question is how change function that check another drives for this folder too.
Is thee any other function that do this too?
Regards,
Posted
Updated 20-Dec-11 6:53am
v2

SHGetSpecialFolderPath only works with the drive windows is installed on.

If you need to check other drive you will have to do that yourself.
 
Share this answer
 
Comments
Chuck O'Toole 20-Dec-11 13:14pm    
Agreed, there is nothing "Special" about the folder name "Program Files" on the "D" drive, it's just another name.
Chuck O'Toole 20-Dec-11 13:15pm    
Oh, sorry for the "4", I mis-clicked and now it won't let me go back and fix it.
Mehdi Gholam 20-Dec-11 13:17pm    
Cheers, no problem.
Hi,

It is not possible with SHGetSpecialFolderPath(). This function will return only the path of concerned CSIDL values.

FYI: We can get the current directory using GetCurrentDirectory(),

GetModuleFileName(): Return the exe's path.


Thanks
 
Share this answer
 
v3
Comments
RaisKazi 21-Dec-11 2:03am    
Edited using "code" tag.
It seems that you have dual OS installed on your hard disk. One on C Drive and the other on D Drive. When you boot with OS installed on C Drive the special folder (like MyDocument, ProgramFiles) from the current OS (i.e. from C Drive) will get liked to CLSIDs. The folders from D drive will be just an another folder for the OS. So, whenever you retrieve the folder name using SHGetSpecialFolderPath() API you'll get the path from the current boot OS i.e. from C Drive.

If you wanna to search all the folder (on all the drives) with 'Program Files' as name, you have to implement your own logic.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900