GetWindowsDirectory
: http://msdn.microsoft.com/en-us/library/ms724454(VS.85).aspxSHGetSpecialFolderPath
: http://msdn.microsoft.com/en-us/library/bb762204(VS.85).aspx
Daniel A. White
2010-03-22 02:02:03
GetWindowsDirectory
: http://msdn.microsoft.com/en-us/library/ms724454(VS.85).aspxSHGetSpecialFolderPath
: http://msdn.microsoft.com/en-us/library/bb762204(VS.85).aspxUsing Win32 API>
For the Windows folder:
TCHAR windir[NUM];
GetWindowsDirectory(windir, NUM);
For program files:
TCHAR pf[NUM];
SHGetSpecialFolderPath(
0,
pf,
CSIDL_PROGRAM_FILES,
FALSE );
Where NUM is the "maximum" size you guesstimate the length of the path is.
Also, note that SHGetSpecialFolderPath
can be used to retrieve other "special" folder including the Windows folder just by replacing the third parameter to any from this list.
Most of these come from SHGetFolderPath, but GetSystemDirectory() returns the absolute location of C:\Windows\System32. Don't use GetWindowsDirectory(). It doesn't do what you want anymore.