打开文件/文件夹属性窗口

📅 2026/7/8 15:10:14 👁️ 阅读次数 📝 编程学习
打开文件/文件夹属性窗口

和鼠标右键->属性是一样的

调用示例

// 调用示例 // 打开文件属性对话框 std::wstring path = L"F:\\code\\test.png"; // "F:\\code" MyUtil::ShowFileProperties(path.c_str());

源码

void MyUtil::ShowFileProperties(LPCTSTR lpFilePath) { // 初始化结构体 SHELLEXECUTEINFO shellInfo = { 0 }; shellInfo.cbSize = sizeof(shellInfo); // 固定写法:打开属性窗口 shellInfo.lpVerb = L"properties"; shellInfo.lpFile = lpFilePath; // 标志: 触发打开属性对话框 // 告诉系统 执行右键菜单里的命令(属性就是右键菜单内置命令) // 没有它,properties 命令不会生效 shellInfo.fMask = SEE_MASK_INVOKEIDLIST; // 执行系统调用 ShellExecuteEx(&shellInfo); }