对不起,我的英语不好,但我希望你能理解我的问题。我在使用 WinAPI 函数时遇到问题StgOpenStorageEx
。我需要获取文件的摘要信息。我找到了一些解决方案,但在所有解决方案中我都需要使用StgOpenStorageEx
. 因为它不在标准模块中,所以我自己声明它是从 ole32.dll 中导出的,如下所示
function StgOpenStorageEx (
const pwcsName : POleStr; //Pointer to the path of the
//file containing storage object
grfMode : LongInt; //Specifies the access mode for the object
stgfmt : DWORD; //Specifies the storage file format
grfAttrs : DWORD; //Reserved; must be zero
pStgOptions : Pointer; //Address of STGOPTIONS pointer
reserved2 : Pointer; //Reserved; must be zero
riid : PGUID; //Specifies the GUID of the interface pointer
out stgOpen : //Address of an interface pointer
IStorage ) : HResult; stdcall; external 'ole32.dll';
接下来我需要像这样使用这个功能
var
res, open: hresult;
stg: IStorage;
PropSetStg: IPropertySetStorage;
PropStg: IPropertyStorage;
FileName: string;
const
IID_IPropertySetStorage : TGUID = '{0000013A-0000-0000-C000-000000000046}';
FmtID_SummaryInformation: TGUID = '{F29F85E0-4FF9-1068-AB91-08002B27B3D9}';
function StgOpenStorageEx (
const pwcsName : POleStr; //Pointer to the path of the
//file containing storage object
grfMode : LongInt; //Specifies the access mode for the object
stgfmt : DWORD; //Specifies the storage file format
grfAttrs : DWORD; //Reserved; must be zero
pStgOptions : Pointer; //Address of STGOPTIONS pointer
reserved2 : Pointer; //Reserved; must be zero
riid : PGUID; //Specifies the GUID of the interface pointer
out stgOpen : //Address of an interface pointer
IStorage ) : HResult; stdcall; external 'ole32.dll';
...
implementation
...
FileName:=OpenDialog1.FileName;
res:=StgOpenStorageEx(PWideChar(FileName),
STGM_READ or STGM_SHARE_DENY_WRITE,
STGFMT_FILE,
0, nil, nil, @IID_IPropertySetStorage, stg);
OleCheck(res);
PropSetStg := Stg as IPropertySetStorage;
open:=PropSetStg.Open(FmtID_SummaryInformation,
STGFMT_FILE or STGM_READ or STGM_SHARE_EXCLUSIVE, PropStg); //open=-2147287038
OleCheck(open); // EOleSysError "%1 could not be found
...
根据指令OLECheck(Open)
,我有一个 EOleSysError“找不到 %1”。
Open
返回 -2147287038
请告诉我我做错了什么 带有完整功能代码的文章
IDE:Embarcadero® Delphi® XE 版本 15.0.3890.34076