Originally posted by ZerOrDie
ok i have been looking around msdn and the best i could find was GetWindowsDirectory()
which is not exactly what i am looking for... here is what i would like to be able to do, i would like to be able to determine using a function the drive letter of the HD or partition where windows has been installed eg: "C:\"
thank you for your time
This works in 2000 & XP...if you need it for 98/95 and it doesnt work, write back and I will get another way of doing it
Code:
#include <iostream>
#include <windows.h>
using std::cout;
using std::endl;
int main(){
DWORD dwSize = ExpandEnvironmentStrings("%SYSTEMDRIVE%",
NULL,0);//Getsize of string needed
if(!dwSize){
cout << "Error" << endl;
return 1;
}
char *szBuff = new char[dwSize];//create buffer to hold result
if(!szBuff){
cout << "Error" << endl;
return 1;
}
if(!ExpandEnvironmentStrings("%HOMEDRIVE%",
szBuff,dwSize)){//Get information
cout << "Error" << endl;
return 1;
}
cout << "Main Drive is " << szBuff << endl;
delete [] szBuff;//Cleanup!!!
return 0;
}