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

相关文章:

  • 2022-02-11
  • 2022-12-23
  • 2021-05-19
  • 2021-07-10
  • 2021-11-06
  • 2021-11-23
  • 2022-01-29
猜你喜欢
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-11
相关资源
相似解决方案