首页 > 其他分享 >MFC-SHGetSpecialFolderPath获取指定的系统路径

MFC-SHGetSpecialFolderPath获取指定的系统路径

时间:2023-04-21 21:44:09浏览次数:43  
标签:Administrator MFC Users Menu 路径 Start COMMON CSIDL SHGetSpecialFolderPath

 

    CString str;
    TCHAR path[MAX_PATH];

    BOOL b = SHGetSpecialFolderPath(NULL, path, CSIDL_PROGRAM_FILES_COMMONX86, 0);//获取指定的系统路径
    /*
    参数1:HWND hwndOwner   窗口所有者的句柄。可以NULL
    参数2:LPTSTR lpszPath  返回路径的缓冲区,该缓冲区的大小至少为MAX_PATH
    参数3:int nFolder      系统路径的CSIDL标识
            CSIDL (constant special item ID list)是系统定义的特殊条目的ID列表
            在vista之后被KNOWNFOLDERID所替代(但为保持兼容性,仍支持CSIDL)
            CSIDL_DESKTOP=0x0000         桌面                                  C:\Users\Administrator\Desktop
            CSIDL_INTERNET=0x0001        Internet Explorer (icon on desktop)
            CSIDL_PROGRAMS=0x0002        Start Menu\Programs                   C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
            CSIDL_CONTROLS=0x0003        My Computer\Control Panel
            CSIDL_PRINTERS=0x0004        My Computer\Printers
            CSIDL_PERSONAL=0x0005        My Documents我的文档                  C:\Users\Administrator\Documents
            CSIDL_FAVORITES=0x0006       <user name>\Favorites收藏夹           C:\Users\Administrator\Favorites
            CSIDL_STARTUP=0x0007         Start Menu\Programs\Startup启动       C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
            CSIDL_RECENT=0x0008          <user name>\Recent最近使用的项目      C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Recent
            CSIDL_SENDTO=0x0009          <user name>\SendTo                    C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\SendTo
            CSIDL_BITBUCKET=0x000a       <desktop>\Recycle Bin
            CSIDL_STARTMENU=0x000b       <user name>\Start Menu                C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu
            CSIDL_MYDOCUMENTS              我的文档                            C:\Users\Administrator\Documents
            CSIDL_MYMUSIC=0x000d         "My Music" folder音乐                 C:\Users\Administrator\Music
            CSIDL_MYVIDEO=0x000e         "My Videos" folder视频                C:\Users\Administrator\Videos
            CSIDL_DESKTOPDIRECTORY=0x0010   桌面                               C:\Users\Administrator\Desktop
            CSIDL_DRIVES=0x0011           My Computer
            CSIDL_NETWORK=0x0012          Network Neighborhood (My Network Places)
            CSIDL_NETHOOD=0x0013          <user name>\nethood                  C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Network Shortcuts
            CSIDL_FONTS=0x0014            windows\fonts  字体                  C:\Windows\Fonts
            CSIDL_TEMPLATES=0x0015                                             C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Templates
            CSIDL_COMMON_STARTMENU=0x0016     All Users\Start Menu             C:\ProgramData\Microsoft\Windows\Start Menu
            CSIDL_COMMON_PROGRAMS=0X0017      All Users\Start Menu\Programs    C:\ProgramData\Microsoft\Windows\Start Menu\Programs
            CSIDL_COMMON_STARTUP=0x0018       All Users\Startup                C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
            CSIDL_COMMON_DESKTOPDIRECTORY=0x0019       All Users\Desktop       C:\Users\Public\Desktop
            CSIDL_APPDATA=0x001a          <user name>\Application Data         C:\Users\Administrator\AppData\Roaming
            CSIDL_PRINTHOOD=0x001b        <user name>\PrintHood
            CSIDL_LOCAL_APPDATA
            CSIDL_LOCAL_APPDATA=0x001c     <user name>\Local Settings\Applicaiton Data (non roaming)
            CSIDL_LOCAL_APPDATA
            CSIDL_ALTSTARTUP=0x001d        non localized startup
            CSIDL_COMMON_ALTSTARTUP=0x001e      non localized common startup
            CSIDL_COMMON_FAVORITES=0x001f
            _SHFOLDER_H_
            CSIDL_INTERNET_CACHE=0x0020
            CSIDL_COOKIES=0x0021
            CSIDL_HISTORY=0x0022
            CSIDL_COMMON_APPDATA=0x0023      All Users\Application Data
            CSIDL_WINDOWS=0x0024             GetWindowsDirectory()
            CSIDL_SYSTEM=0x0025              GetSystemDirectory()
            CSIDL_PROGRAM_FILES=0x0026                                        C:\Program Files
            CSIDL_MYPICTURES=0x0027                                           C:\Program Files\My Pictures
            _SHFOLDER_H_
            CSIDL_PROFILE=0x0028        USERPROFILE
            CSIDL_SYSTEMX86=0x0029      x86 system directory on RISC
            CSIDL_PROGRAM_FILESX86=0x002a        x86                         C:\Program Files on RISC
            CSIDL_PROGRAM_FILES_COMMON=0x002b                                C:\Program Files\Common
            CSIDL_PROGRAM_FILES_COMMONX86=0x002c        x86                  C:\Program Files (x86)\Common Files
            CSIDL_COMMON_TEMPLATES=0x002d        All Users\Templates
            CSIDL_COMMON_DOCUMENTS=0x002e        All Users\Documents
            CSIDL_COMMON_ADMINTOOLS=0x002f       All Users\Start Menu\Programs\Administrative Tools
            CSIDL_ADMINTOOLS=0x0030              <user name>\Start Menu\Programs\Administrative Tools
            CSIDL_CONNECTIONS=0x0031             Network and Dial-up Connections
            CSIDL_COMMON_MUSIC=0x0035            All Users\My Music
            CSIDL_COMMON_PICTURES=0x0036         All Users\My Pictures
            CSIDL_COMMON_VIDEO              0x0037        // All Users\My Video
            CSIDL_RESOURCES                 0x0038        // Resource Direcotry
            CSIDL_RESOURCES_LOCALIZED       0x0039        // Localized Resource Direcotry
            CSIDL_COMMON_OEM_LINKS          0x003a        // Links to All Users OEM specific apps
            CSIDL_CDBURN_AREA               0x003b        // USERPROFILE\Local Settings\Application Data\Microsoft\CD Burning
            CSIDL_COMPUTERSNEARME           0x003d        // Computers Near Me (computered from Workgroup membership)
            CSIDL_FLAG_CREATE               0x8000        // combine with CSIDL_ value to force folder creation in SHGetFolderPath()
            CSIDL_FLAG_DONT_VERIFY          0x4000        // combine with CSIDL_ value to return an unverified folder path
            CSIDL_FLAG_DONT_UNEXPAND        0x2000        // combine with CSIDL_ value to avoid unexpanding environment variables
            CSIDL_FLAG_NO_ALIAS             0x1000        // combine with CSIDL_ value to insure non-alias versions of the pidl
            CSIDL_FLAG_PER_USER_INIT        0x0800        // combine with CSIDL_ value to indicate per-user init (eg. upgrade)
            CSIDL_FLAG_MASK                 0xFF00        // mask for all possible flag values


    参数4:BOOL fCreate  指示文件夹不存在时是否创建。为false则不创建,否则创建

    返回值:函数执行成功则返回true,否则返回false
    */

    str = path;


    ::OutputDebugString(str);

 

 

 

 

 

 

 

标签:Administrator,MFC,Users,Menu,路径,Start,COMMON,CSIDL,SHGetSpecialFolderPath
From: https://www.cnblogs.com/liming19680104/p/17341910.html

相关文章

  • CSS3: 利用分层动画让元素沿弧形路径运动
    译者注:部分代码示例中可以看效果(作者写在博文里面了…),我偷懒把它做成Gif图了。 CSS的animations(动画)和transitions(变换)擅于实现从点A到点B的直线运动,运动轨迹是直线路径。给一个元素添加了animation或者transition以后,无论你如何调整贝塞尔曲线,都无法让它沿着弧形路......
  • 用C#写一个上传下载文件至OSS后返回文件路径用DES加密解密
    废话不多说,直接上代码:usingAliyun.OSS;//引入阿里云OSSSDKusingSystem;usingSystem.IO;usingSystem.Security.Cryptography;//引入.NETFramework中的加密库usingSystem.Text;publicclassOSSHelper{///<summary>///将文件上传至OSS,并使用D......
  • Aras学习笔记 (53) - 根据ID快速找到文件Vault路径
    Step1:首先在对象类File中根据名称找到ID;Step2:右键文件-->Share-->CopyID;Step3:在Console中输入下命令:top.aras.IomInnovator.getFileUrl("[文件ID]",top.aras.Enums.UrlType.SecurityToken)结果如下: ......
  • MFC-IsWow64Process 32位进程是否运行在64位操作系统中
     CStringstr;BOOLbIsWow64=FALSE;BOOLb=IsWow64Process(GetCurrentProcess(),&bIsWow64);//32位进程是否运行在64位操作系统中/*指定进程是否运行在64位操作系统的32环境(WOW64)下参数1:HANDLEhProcess进程的句柄。句柄必须具有PROCESS_......
  • MFC-GetCurrentProcess获取当前进程的伪句柄
     CStringstr;HANDLEhandle=GetCurrentProcess();//获取当前进程的伪句柄/*返回当前进程的伪句柄(始终返回-1)不要直接使用-1这个值,为了将来的兼容性请使用GetCurrentProcess伪句柄可以在当前进程中使用,如果需要跨进程通信,那么必须拿出自己真实......
  • MFC-GetNativeSystemInfo获取当前CPU信息
     CStringstr;SYSTEM_INFOlpSystemInfo;GetNativeSystemInfo(&lpSystemInfo);//获取当前CPU信息/*在一个64位的应用中调用此函数,那它等效于GetSystemInfo*/WORDw=lpSystemInfo.wProcessorArchitecture;//处理器的体系结构......
  • POJ3984 迷宫问题(BFS 记忆路径)
    迷宫问题TimeLimit:1000MS     MemoryLimit:65536KB     64bitIOFormat:%I64d&%I64uSubmit Status Practice POJ3984SystemCrawler (2014-09-11)Description定义一个二维数组: intmaze[5][5]={0,1,0,0......
  • MFC-添加资源
     添加图片资源           ......
  • MFC-BeginPaint和EndPaint
     只能用在消息处理函数WindowProc的WM_PAINT消息中在WM_PAINT消息中必须使用BeginPaint和EndPaint       ......
  • CF 580C- Kefa and Park, 1500 / 树的遍历 / 根节点到叶节点的路径上某性质的点不能
    CF580C-KefaandPark这个1500的题这么水?这还不如1200、1300的思维题我开始没考虑周全,这题给出的连边没有讲都是从父节点连向子节点,所有要建双边。#include<iostream>#include<cstring>usingnamespacestd;constintN=1e5+10,M=N*2;typedeflonglon......