怎么样得到桌面和启动的路径

解决方案 »

  1.   

    SHGetSpecialFolderPath
    Retrieves the path of a special folder, identified by its CSIDL. 
    BOOL SHGetSpecialFolderPath(
        HWND hwndOwner,
        LPTSTR lpszPath,
        int nFolder,
        BOOL fCreate
    );
    CSIDL_DESKTOP
    CSIDL_STARTUP
      

  2.   

    LPITEMIDLIST pidl;
    LPMALLOC pShellMalloc;
    const int nFolder[2]={CSIDL_DESKTOPDIRECTORY,CSIDL_STARTMENU};
    if(SUCCEEDED(SHGetMalloc(&pShellMalloc)))
    {
     char Path[MAX_PATH+1];
     for(int i=0;i<2;i++)
     {
     if(SUCCEEDED(SHGetSpecialFolderLocation(NULL,nFolder[i],&pidl)))
     {
     if(SHGetPathFromIDList(pidl,Path))
     {
     if(i==0)
     m_strDesktopPath=Path;
     else
     m_strStartMenuPath=Path;
     }
     pShellMalloc->Free(pidl);
     }
     }
     pShellMalloc->Release();
    }