积极答复者
StgOpenStorage 这个函数怎么打开chm文件啊

问题
-
我用C# 同样也调用 StgOpenStorage 可以打开 chm 文件
为什么直接用 vc 却返回 STG_E_FILEALREADYEXISTS 不是复合文件啊
但为什么 用C# 又可以也
- 已移动 VisualElevenModerator 2011年7月5日 0:14 C#相关问题 (发件人:Visual C++)
- 已移动 feiyun0112Moderator 2011年7月5日 4:45 C++问题 (发件人:Visual C#)
答案
-
最后一章,
您好!
>>hr = ::StgOpenStorage(CONVERT(filename), NULL,STGM_READ | STGM_SHARE_EXCLUSIVE, 0, NULL, &pStorage);
这段代码中,请问CONVERT方法您具体是怎么定义的,它并不是个Windows API. 另外 filename你是怎么定义的?
以下链接是讲解StgOpenStorage 函数的(注意其中的一句话“Do not use it to open directories, files, or summary catalogs. Nested storage objects can only be opened using their parent IStorage::OpenStorage method.”)。http://msdn.microsoft.com/en-us/library/aa380341(VS.85).aspx
Lucy
Lucy Liu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已标记为答案 VisualElevenModerator 2011年7月11日 0:09
全部回复
-
C#
vc[ComImport] [Guid("88CC31DE-27AB-11D0-9DF9-00A0C922E6EC")] [SuppressUnmanagedCodeSecurity] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface ITStorage { [return: MarshalAs(UnmanagedType.Interface)] IStorage StgCreateDocfile([In, MarshalAs(UnmanagedType.BStr)] string pwcsName, int grfMode, int reserved); [return: MarshalAs(UnmanagedType.Interface)] IStorage StgCreateDocfileOnILockBytes(ILockBytes plkbyt, int grfMode, int reserved); int StgIsStorageFile([In, MarshalAs(UnmanagedType.BStr)] string pwcsName); int StgIsStorageILockBytes(ILockBytes plkbyt); [return: MarshalAs(UnmanagedType.Interface)] IStorage StgOpenStorage([In, MarshalAs(UnmanagedType.BStr)] string pwcsName, IntPtr pstgPriority, [In, MarshalAs(UnmanagedType.U4)] int grfMode, IntPtr snbExclude, [In, MarshalAs(UnmanagedType.U4)] int reserved); [return: MarshalAs(UnmanagedType.Interface)] IStorage StgOpenStorageOnILockBytes(ILockBytes plkbyt, IStorage pStgPriority, int grfMode, IntPtr snbExclude, int reserved); int StgSetTimes([In, MarshalAs(UnmanagedType.BStr)] string lpszName, System.Runtime.InteropServices.ComTypes.FILETIME pctime, System.Runtime.InteropServices.ComTypes.FILETIME patime, System.Runtime.InteropServices.ComTypes.FILETIME pmtime); int SetControlData(ITS_Control_Data pControlData); int DefaultControlData(ITS_Control_Data ppControlData); int Compact([In, MarshalAs(UnmanagedType.BStr)] string pwcsName, ECompactionLev iLev); }
IStorage *pStorage = NULL; IPropertySetStorage *pPropSetStg = NULL; HRESULT hr; hr = ::StgOpenStorage(CONVERT(filename), NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, NULL, &pStorage);
-
没人回答 怎么把帖子移到c# 去了!!!!
c# 没问题 是vc 有问题!!!
对不起,我还以为您问的关于C#的问题。
您可以参考一下这骗文章关于COM的,希望对您有所帮助
http://www.vckbase.com/document/viewdoc/?id=1483
Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development. -
最后一章,
您好!
>>hr = ::StgOpenStorage(CONVERT(filename), NULL,STGM_READ | STGM_SHARE_EXCLUSIVE, 0, NULL, &pStorage);
这段代码中,请问CONVERT方法您具体是怎么定义的,它并不是个Windows API. 另外 filename你是怎么定义的?
以下链接是讲解StgOpenStorage 函数的(注意其中的一句话“Do not use it to open directories, files, or summary catalogs. Nested storage objects can only be opened using their parent IStorage::OpenStorage method.”)。http://msdn.microsoft.com/en-us/library/aa380341(VS.85).aspx
Lucy
Lucy Liu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已标记为答案 VisualElevenModerator 2011年7月11日 0:09