UINT GetWindowsDirectory( LPTSTR lpBuffer, // address of buffer for Windows directory UINT uSize // size of directory buffer );UINT GetSystemDirectory( LPTSTR lpBuffer, // address of buffer for system directory UINT uSize // size of directory buffer );DWORD GetTempPath( DWORD nBufferLength, // size, in characters, of the buffer LPTSTR lpBuffer // pointer to buffer for temp. path );WINSHELLAPI HRESULT WINAPI SHGetSpecialFolderPath( HWND hwndOwner, LPTSTR lpszPath, int nFolder, BOOL fCreate );
you can try this ExpandEnvironmentStrings The ExpandEnvironmentStrings function expands environment-variable strings and replaces them with their defined values. DWORD ExpandEnvironmentStrings( LPCTSTR lpSrc, // string with environment variables LPTSTR lpDst, // string with expanded strings DWORD nSize // maximum characters in expanded string );
GetSystemWindowsDirectory等等
LPTSTR lpBuffer, // address of buffer for Windows directory
UINT uSize // size of directory buffer
);UINT GetSystemDirectory(
LPTSTR lpBuffer, // address of buffer for system directory
UINT uSize // size of directory buffer
);DWORD GetTempPath(
DWORD nBufferLength, // size, in characters, of the buffer
LPTSTR lpBuffer // pointer to buffer for temp. path
);WINSHELLAPI HRESULT WINAPI SHGetSpecialFolderPath(
HWND hwndOwner,
LPTSTR lpszPath,
int nFolder,
BOOL fCreate
);
我想问一下有没有Win32API(不要ShellAPI)能够获得程序的路径的(即c:\Program files这样的)。
SHGetSpecialFolderPath(NULL,szDir,CSIDL_COMMON_PROGRAMS,FALSE);
非要使用Shell API?????
ExpandEnvironmentStrings
The ExpandEnvironmentStrings function expands environment-variable strings and replaces them with their defined values. DWORD ExpandEnvironmentStrings(
LPCTSTR lpSrc, // string with environment variables
LPTSTR lpDst, // string with expanded strings
DWORD nSize // maximum characters in expanded string
);
但你想要更多的最好是到注册表中找HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\explorer\Shell Folders