zoukankan      html  css  js  c++  java
  • C++ Builder获取系统文件的路径

    取得路径的程序:(注意红色字体,由于博客显示问题,所以中间加了空格,大家自己把空格去掉即可)

    // ---------------------------------------------------------------------------
    #define NO_WIN32_LEAN_AND_MEAN
    #inclu de <vcl.h>
    #pragma hdrstop

    #inclu de "Unit1.h"
    #inclu de "shlobj.h "
    // ---------------------------------------------------------------------------
    #pragma package(smart_init)
    #pragma resource "*.dfm"
    TForm1 *Form1;

    // ---------------------------------------------------------------------------
    __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) {
    }

    // ---------------------------------------------------------------------------
    void __fastcall TForm1::FormShow(TObject *Sender) {
    LPITEMIDLIST pidl;
    LPMALLOC pShellMalloc;
    //定义快捷方式的数据文件名

    char szDir[MAX_PATH];

    if (S?(SHGetMalloc(&pShellMalloc))) {
    // 取得快捷方式的PIDL

    if (S?(SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl))){

    // 把PIDL转换为路径名
    if (SHGetPathFromIDList(pidl, szDir)) {
    //szDir就是所要取得的路径

    Label1->Caption = szDir;
    }

    pShellMalloc->Free(pidl);
    }

    pShellMalloc->Release();
    }

    }

    将CSIDL_STARTUP变换成其他,如
    CSIDL_ADMINTOOLS
    表示当前用户的“管理工具”系统文件夹
    CSIDL_APPDATA
    表示当前用户的特定的应用程序数据存储文件夹,例如:C:Documents and SettingsusernameApplication Data
    CSIDL_BITB KET
    表示回收站
    CSIDL_COMMON_ADMINTOOLS
    表示所有用户的“管理工具”系统文件夹
    CSIDL_COMMON_ALTSTARTUP
    表示所有用户的 (只支持WINDOWS NT 系统)
    CSIDL_COMMON_APPDATA
    表示所有用户的特定的应用程序数据存储文件夹,例如:C:Documents and SettingsAll UsersApplication Data
    CSIDL_COMMON_DESKTOPDIRECTORY
    表示所有用户的“桌面”文件夹,例如:C:Documents and SettingsAll UsersDesktop。
    CSIDL_COMMON_DOCUMENTS
    表示所有用户的“我的文档”文件夹,例如:C:Documents and SettingsAll UsersDocuments
    CSIDL_COMMON_FAVORITES
    表示所有用户的“我的收藏夹”文件夹。
    CSIDL_COMMON_PROGRAMS
    表示所有用户的“程序”文件夹,例如:C:Documents and SettingsAll UsersStart MenuPrograms
    CSIDL_COMMON_STARTMENU
    表示所有用户的“开始菜单”文件夹,例如:C:Documents and SettingsAll UsersStart Menu
    CSIDL_COMMON_STARTUP
    表示所有用户的“启动”文件夹,例如:C:Documents and SettingsAll UsersStart MenuProgramsStartup
    CSIDL_COMMON_TEMPLATES
    表示所有用户的“模块”文件夹,例如:C:Documents and SettingsAll UsersTemplates
    CSIDL_CONTROLS
    表示“控制面板”文件夹
    CSIDL_COOKIES
    表示当前用户Internet Explorer的cookie 文件夹,例如:C:Documents and SettingsusernameCookies
    CSIDL_DESKTOP
    表示“桌面”虚拟文件夹,包含了计算机中的所有内容
    CSIDL_DESKTOPDIRECTORY
    表示当前用户的“桌面”文件夹,例如:C:Documents and SettingsusernameDesktop

  • 相关阅读:
    归并排序java实现
    linux中压缩与备份命令总结
    Debug查看Struts2中ExceptionMappingInterceptor拦截器怎么把ExceptionHolder放入值栈中,以及理解拦截器的工作原理。。。
    Linux文件与目录管理命令小结
    (转)常用的正则表达式
    Neither BindingResult nor plain target obiect available as request attribute
    sping mvc访问.js,.css,.img等静态文件
    spring security学习(二)
    初始spring security(一)
    在myeclipse中使用maven前常见错误及解决办法
  • 原文地址:https://www.cnblogs.com/blogpro/p/11446018.html
Copyright © 2011-2022 走看看