在vc6.0下,使用SHGetFolderPath,确提示error C2065: 'SHGetFolderPath' : undeclared identifier
加#include <shlobj.h>
加shell32.dll都不行啊!!

解决方案 »

  1.   

    ::SHBrowseForFolder
    不用其他!
    你给我100分吧~// 新界面#define BIF_USENEWUI 0x0050bool GetFolderX(CString* folderpath, const char* szCaption , const HWND hOwner )
    {
    bool retVal = false; // The BROWSEINFO struct tells the shell 
    // how it should display the dialog.
    BROWSEINFO bi;
    memset(&bi, 0, sizeof(bi)); bi.ulFlags   = BIF_USENEWUI  ;
    // bi.ulFlags   = BIF_RETURNONLYFSDIRS | BIF_DONTGOBELOWDOMAIN | BIF_STATUSTEXT;
    bi.hwndOwner = hOwner;
    bi.lpszTitle = szCaption; // must call this if using BIF_USENEWUI
    ::OleInitialize(NULL); // Show the dialog and get the itemIDList for the selected folder.
    LPITEMIDLIST pIDL = ::SHBrowseForFolder(&bi); if(pIDL != NULL)
    {
    // Create a buffer to store the path, then get the path.
    char buffer[_MAX_PATH] = {'\0'};
    if(::SHGetPathFromIDList(pIDL, buffer) != 0)
    {
    // Set the string value.
    folderpath->Format("%s", buffer);
    retVal = true;
    } // free the item id list
    CoTaskMemFree(pIDL);
    } ::OleUninitialize(); return retVal;
    }
      

  2.   

    //----------------
    // in stdafx.h
    #define _WIN32_IE 0x500
    #include <shlobj.h>
    //-----------------
    CString path;
    LPTSTR p = path.GetBuffer(MAX_PATH);
    HRESULT hr = ::SHGetFolderPath(CSIDL_INTERNET_CACHE, NULL, SHGFP_TYPE_CURRENT, p);
    if(SUCCEEDED(hr))
       { /* succeeded */
        path.ReleaseBuffer();
        ...your code here
       } /* succeeded */
    else
       { /* failed */
        path.ReleaseBuffer();
        ...failure code here
       } /* failed */
      

  3.   

    不好意思啊,我搞错了。两码事。VC6确实编译不了这个,需要一个头文件shlobj.h(MSDN说是shfolder.h),这个头文件VC6里的陈旧了,需要下载新的MICROSOFT SDK包,用那里边的头文件替换掉VC6的。SDK地址:
    http://www.microsoft.com/downloads/details.aspx?FamilyId=A55B6B43-E24F-4EA3-A93E-40C0EC4F68E5&displaylang=en或者跟别人要一个100分我不要了~~~~~~~~~
      

  4.   

    安装一个较新的Platform SDK应该就可以了。
      

  5.   

    這個可以用。 #define _WIN32_IE 0x500加這個就可以了,好像是這個,以前我用過,就是版本不對,加一個宏聲明就可以了
      

  6.   

    或者动态载入,这个函数在shfolder.dll中。
      

  7.   

    使用SHGetSpecialFolderPath(NULL, lpszPath, CSIDL_LOCAL_APPDATA, false)
    一切得以解决,什么其他工作都不用做
    谢谢大家!!