0
这是我的代码:获取Windows桌面路径
#include <Windows.h>
#include <ShlObj.h>
#include <iostream>
using namespace std;
int main()
{
LPTSTR myPath = NULL;
SHGetSpecialFolderPath(0, myPath, CSIDL_COMMON_DESKTOPDIRECTORY, FALSE);
if(myPath != NULL)
cout << "It returns something" << endl;
else
cout << "It returns nothing" << endl;
system("PAUSE");
return 0;
}
但mypath中没有返回。我只想获取桌面路径。我在Windows 7 64位。
谢谢。我不用Windows API工作,所以这是我第一次。 T_CHAR和LPTSTR有什么区别? LPTSTR无法接收系统调用的输出?谢谢! – FacundoGFlores
LPTSTR是一个指针,在你的代码中它没有指向任何东西。你需要将函数传递给一个可以存储字符串的缓冲区(一块内存)。 –
'LPTSTR'是一个指向'TCHAR'的指针。你应该使用'TCHAR'而不是'T_CHAR'。 –