VC++显示文件或文件夹属性

 

  When you select a file or folder in Explorer window, and choose 'Properties' from the menu, you get the properties window that contains some essential information about the file: The size of file, created date, modified date, attributes, and so on.
  It's possible to display this properties window programmatically, by using the ShellExecuteEx API function. 
  The function below accept 2 parameters, and displays the properties window of the file: 
  hwnd - The handle of the window that calls this function. 
  lpszFile - The file or folder that you want to display its properties. 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 
void ShowFileProperties(HWND hwnd, LPCWSTR lpszFile)
{
    SHELLEXECUTEINFO ShExecInfo = {
0};

    ShExecInfo.cbSize = 
sizeof(SHELLEXECUTEINFO);
    ShExecInfo.fMask = SEE_MASK_INVOKEIDLIST ;
    ShExecInfo.hwnd = hwnd;
    ShExecInfo.lpVerb = _T(
"properties");
    ShExecInfo.lpFile = lpszFile;
    ShExecInfo.lpParameters = _T(
""); 
    ShExecInfo.lpDirectory = 
NULL;
    ShExecInfo.nShow = SW_SHOW;
    ShExecInfo.hInstApp = 
NULL
    ShellExecuteEx(&ShExecInfo);
}

 

posted on 2017-11-02 18:13  我来乔23  阅读(474)  评论(1编辑  收藏  举报

导航