码迷,mamicode.com
首页 > Windows程序 > 详细

delphi 读写文件属性

时间:2015-09-11 16:12:56      阅读:251      评论:0      收藏:0      [点我收藏+]

标签:

uses comobj,activex;
const
  IID_IPropertySetStorage:TGUID = ‘{0000013A-0000-0000-C000-000000000046}‘;

  FMTID_SummaryInformation:TGUID=‘{F29F85E0-4FF9-1068-AB91-08002B27B3D9}‘;


function StgOpenStorageEx( pwcsName: POleStr; grfMode: dword;
  stgfmt: DWORD; grfAttrs: DWORD; pStgOptions: STGOPTIONS; reserved2: Pointer;
  riid: PGUID; out ppObjectOpen: IPropertySetStorage): HResult; stdcall;external ‘ole32.dll‘;

var
  pPropSetStg: IPropertySetStorage;
  pPropStg:IPropertyStorage;
  propspec:TPropSpec;
  propWrite:TPropVariant;


StgOpenStorageEx(PWChar(‘文件名‘),STGM_DIRECT or STGM_SHARE_EXCLUSIVE or STGM_READWRITE,STGFMT_ANY, 0,nil,nil ,@IID_IPropertySetStorage, pPropSetStg);
//写入
pPropSetStg.Create( FMTID_SummaryInformation, FMTID_SummaryInformation,0,STGM_CREATE or STGM_READWRITE or STGM_SHARE_EXCLUSIVE,pPropStg);
propWrite.vt:= VT_LPWSTR;
propWrite.pwszVal:= pwchar(‘写入的数据‘);
pPropStg.WriteMultiple( 1, @propspec,@propWrite, PID_FIRST_USABLE );
//读出
pPropSetStg.Open( FMTID_SummaryInformation,STGM_READ or STGM_SHARE_EXCLUSIVE,pPropStg );
pPropStg.ReadMultiple( 1, @propspec, @propWrite );

delphi 读写文件属性

标签:

原文地址:http://my.oschina.net/jingshishengxu/blog/504975

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!