下面代码的函数为什么没定义呀,标准的win32系统api却不能调用,我用vb6调用都没有问题,但vc6却不能调用,难道vc真的不行吗?
下面是微软官方的一个例子,我还以为是vs2012之类的高版本才能用呢,但一看这api,完全是win2000就有的呀,我用xp+vc6.0 sp6,已定义网上所谓的
#define _WIN32_NT 0X0500
#define WINVER 0x0500
#define _WIN32_WINNT 0x0500
都定义了,但还是不认识我呀:error C2065: 'SHGetFolderLocation' : undeclared identifier
#include <shlobj.h> #include <shlwapi.h> #include <iostream.h> #include <objbase.h> int main() { IShellFolder *psfParent = NULL; LPITEMIDLIST pidlSystem = NULL; LPCITEMIDLIST pidlRelative = NULL; STRRET strDispName; TCHAR szDisplayName[MAX_PATH]; HRESULT hr; hr = SHGetFolderLocation(NULL, CSIDL_SYSTEM, NULL, NULL, &pidlSystem); hr = SHBindToParent(pidlSystem, IID_IShellFolder, (void **) &psfParent, &pidlRelative); if(SUCCEEDED(hr)) { hr = psfParent->GetDisplayNameOf(pidlRelative, SHGDN_NORMAL, &strDispName); hr = StrRetToBuf(&strDispName, pidlSystem, szDisplayName, sizeof(szDisplayName)); cout << "SHGDN_NORMAL - " <<szDisplayName << '\n'; } psfParent->Release(); CoTaskMemFree(pidlSystem); return 0; }
--------------------Configuration: ctest - Win32 Debug-------------------- Compiling... ctest.cpp c:\documents and settings\knife\桌面\ctest\ctest.cpp(31) : error C2065: 'SHGetFolderLocation' : undeclared identifier c:\documents and settings\knife\桌面\ctest\ctest.cpp(31) : error C2065: 'CSIDL_SYSTEM' : undeclared identifier c:\documents and settings\knife\桌面\ctest\ctest.cpp(33) : error C2065: 'SHBindToParent' : undeclared identifier c:\documents and settings\knife\桌面\ctest\ctest.cpp(38) : error C2065: 'StrRetToBuf' : undeclared identifier c:\documents and settings\knife\桌面\ctest\ctest.cpp(46) : error C2065: 'getchar' : undeclared identifier 执行 cl.exe 时出错. ctest.exe - 1 error(s), 0 warning(s)
已改用vs2013了,没有这个问题了