views:

44

answers:

2

i would like to know the function which returns the drive where the windows has been installed. for example if we run a program with following code in windows which is installed in "C:\" temp_char = getWindowsInstalledDrive();

should return "C:\".

please point me to that function if you know. it should be a C/C++ function. Thanks.

+2  A: 

Use GetWindowsDirectory, and then extract the drive from the first three characters. This function is described as "legacy" in the help, but should work on all existing Windows versions.

anon
+2  A: 

You can use GetSystemDirectory(): http://msdn.microsoft.com/en-us/library/ms724373%28VS.85%29.aspx and then take the first 3 letters.

IVlad