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;
}

原文链接: https://www.cnblogs.com/lartely/archive/2011/04/11/2012159.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    c++使用(Shell32.dll)GetDetailsOf 接口获取文件属性

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/23809

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月8日 上午1:42
下一篇 2023年2月8日 上午1:42

相关推荐