delphi 读写文件属性

原创
2015/09/11 15:13
阅读数 295
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 );
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部