zoukankan      html  css  js  c++  java
  • c++使用(Shell32.dll)GetDetailsOf 接口获取文件属性

    使用getdetailsof 接口获取文件属性[转自]

    #include <iostream>
    #include <string>
    #import <Shell32.dll>
    
    using namespace std;
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	CoInitialize(NULL);
    
    	Shell32::IShellDispatchPtr ptrShell; 
    	ptrShell.CreateInstance(__uuidof(Shell32::Shell)); 
    	_variant_t var((short)Shell32::ssfRECENT); 
    
    	Shell32::FolderPtr ptrFolder = ptrShell->NameSpace("C:\\");
    
    	Shell32::FolderItemPtr ptrItem = ptrFolder->ParseName("apple.avi");
    
    	for( int i = 0; i < 50; i++ ) 
    	{ 
    		string strName = ptrFolder->GetDetailsOf(0, i); 
    		cout << i <<strName << ":"; 
    		//string strValue = ptrFolder->GetDetailsOf(ptrItem, i); 
    		string strValue = ptrFolder->GetDetailsOf( _variant_t((IDispatch *)ptrItem), i);
    
    		cout << strValue << endl; 
    	} 
    
    	ptrItem.Release();
    	ptrFolder.Release();
    	ptrShell.Release(); 
    
    	CoUninitialize(); 
    	return 0;
    }
  • 相关阅读:
    0803C#如何高效读取EXCEL文件
    0711笔记
    笔记0709
    0708:XML专题
    笔记0705
    笔记0704
    笔记0627
    笔记0626
    gridview合并单元格
    笔记0624
  • 原文地址:https://www.cnblogs.com/lartely/p/2012159.html
Copyright © 2011-2022 走看看