您的位置:首页 > 其它

获取文件详细信息的方法

2013-01-02 12:29 399 查看
#include "stdafx.h"
#include <iostream>
#include <string.h>
#include <windows.h>

#import <Shell32.dll>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    CoInitialize(NULL);
    do
    {
       
        Shell32::IShellDispatchPtr ptrShell;
        if(ptrShell.CreateInstance(__uuidof(Shell32::Shell)) != S_OK)
            break;

        wstring loWstrFolder = L"E:\\TEST";
        //wchar_t npFilePath[] = L"E:\\1.jpg";
        //CString lstrFilePath(npFilePath);
        //lstrFilePath = lstrFilePath.Left(lstrFilePath.Find(PathFindFileName(npFilePath)));
        Shell32::FolderPtr ptrFolder = ptrShell->NameSpace(loWstrFolder.c_str());
        if(NULL == ptrFolder)
            break;

        Shell32::FolderItemPtr ptrItem = ptrFolder->ParseName(L"1.jpg");
        if(NULL == ptrItem)
            break;

        // 3表示获取的信息内容索引序号,3代表获取最后修改日期
        string lstrValue = ptrFolder->GetDetailsOf( _variant_t((IDispatch *)ptrItem), 3);

    } while (false);

    CoUninitialize();

    return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: