• 获取系统的相关文件夹


    获取系统的相关文件夹

    SHGetSpecialFolderPath

    Retrieves the path of a special folder, identified by its CSIDL.

    BOOL SHGetSpecialFolderPath(

        HWND hwndOwner,

        LPTSTR lpszPath,

        int nFolder,

        BOOL fCreate

    );

     
    #define CSIDL_WINDOWS 36
    #define CSIDL_WINDOWS 37
    #define CSIDL_PROGRAM_FILES 38
    #define CSIDL_MY_PICTURES 39
     
     
     

    获取系统桌面的文件夹的路径

        char szPath[MAX_PATH];
        SHGetSpecialFolderPathNULLszPathCSIDL_DESKTOP, false );
        
        CString s;
        s.Format("%s",szPath);

        SetWindowTexts );

     

    效果图:

     
     
     

    SHGetPathFromIDList

    Converts an item identifier list to a file system path.

    BOOL SHGetPathFromIDList(

        LPCITEMIDLIST pidl,

        LPSTR pszPath

    );

     
     

    获取系统桌面的文件夹的路径 写法2

        LPITEMIDLIST lpItemIdList;
        TCHAR szPath[MAX_PATH];
        ::SHGetSpecialFolderLocationNULLCSIDL_DESKTOP, &lpItemIdList );
        ::SHGetPathFromIDList(lpItemIdListszPath);
        
        SetWindowTextszPath );

    效果图:

     

    ID

    nFolder

    文件夹

    路径

    1

    CSIDL_DESKTOP

    桌面

    C:\Users\Administrator\Desktop

    2

    CSIDL_INTERNET

    3

    CSIDL_PROGRAMS

    C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs

    4

    CSIDL_CONTROLS

    5

    CSIDL_PRINTERS

    6

    CSIDL_PERSONAL

    我的文档

    D:\Administrator\Documents

    7

    CSIDL_FAVORITES

    D:\Administrator\Favorites

    8

    CSIDL_STARTUP

    C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

    9

    CSIDL_RECENT

    C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Recent

    10

    CSIDL_SENDTO

    C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\SendTo

    11

    CSIDL_BITBUCKET

    12

    CSIDL_STARTMENU

    13

    CSIDL_DESKTOPDIRECTORY

    14

    CSIDL_DRIVES

    C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu

    15

    CSIDL_NETWORK

    16

    CSIDL_NETHOOD

    网络邻居

    C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Network Shortcuts

    17

    CSIDL_FONTS

    C:\Windows\Fonts

    18

    CSIDL_TEMPLATES

    C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Templates

    19

    CSIDL_COMMON_STARTMENU

    C:\ProgramData\Microsoft\Windows\Start Menu

    20

    CSIDL_COMMON_PROGRAMS

    开始菜单

    C:\ProgramData\Microsoft\Windows\Start Menu\Programs

    21

    CSIDL_COMMON_STARTUP

    C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup

    22

    CSIDL_COMMON_DESKTOPDIRECTORY

    C:\Users\Public\Desktop

    23

    CSIDL_APPDATA

    C:\Users\Administrator\AppData\Roaming

    24

    CSIDL_PRINTHOOD

    C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Printer Shortcuts

    25

    CSIDL_ALTSTARTUP

    启动

    C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

    26

    CSIDL_COMMON_ALTSTARTUP

    C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup

    27

    CSIDL_COMMON_FAVORITES

    D:\Administrator\Favorites

    28

    CSIDL_INTERNET_CACHE

    IE临时

    C:\Users\Administrator\AppData\Local\Microsoft\Windows\Temporary Internet Files

    29

    CSIDL_COOKIES

    C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Cookies

    30

    CSIDL_HISTORY

    C:\Users\Administrator\AppData\Local\Microsoft\Windows\History

    31

    36

    Windows目录

    C:\Windows

    32

    37

    System32

    C:\Windows\System32

    33

    38

    Program Files

    C:\Program Files

    34

    39

    我的图片

    D:\Administrator\Pictures

    35

    36

     
     
     
     
     
     
     
     




  • 相关阅读:
    Python连接MySQL数据库之pymysql模块使用
    前端基础之BOM和DOM
    前端基础之JavaScript
    前端基础之CSS
    前端知识之HTML内容
    Python基础—名称空间(Day10)
    Python基础—装饰器(Day11)
    Python基础—迭代器、生成器(Day13)
    Python基础—文件操作(Day8)
    Python基础—函数(Day9)
  • 原文地址:https://www.cnblogs.com/xe2011/p/2923680.html
Copyright © 2020-2023  润新知