📄 subject_48913.htm
字号:
<p>
序号:48913 发表者:Rikcuo Akira 发表日期:2003-08-04 23:18:14
<br>主题:在C寫著以下敘述,若轉為C++,要如何寫呢
<br>内容:在C寫著以下敘述,若轉為C++,要如何寫呢??<BR><BR>IStorageVtbl MyIStorageTable = {Storage_QueryInterface,<BR>Storage_AddRef,<BR>Storage_Release,<BR>Storage_CreateStream,<BR>Storage_OpenStream,<BR>Storage_CreateStorage,<BR>Storage_OpenStorage,<BR>Storage_CopyTo,<BR>Storage_MoveElementTo,<BR>Storage_Commit,<BR>Storage_Revert,<BR>Storage_EnumElements,<BR>Storage_DestroyElement,<BR>Storage_RenameElement,<BR>Storage_SetElementTimes,<BR>Storage_SetClass,<BR>Storage_SetStateBits,<BR>Storage_Stat};
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:木一 回复日期:2003-08-04 23:23:30
<br>内容:C++更简单拉,在C下要你自己写virtual table,C++则由编译器自动实现。<BR>从你写的可以看出,是一个COM的接口。<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:萧七 回复日期:2003-08-05 09:36:52
<br>内容:定义接口:<BR>class IStorage : public IUnknown<BR>{ <BR> //声明你的那些接口函数<BR>}<BR><BR>定义COM对象<BR>class MyIstorage : public IStorage<BR>{<BR>//实现接口函数,包括IUnknown的三个接口成员函数<BR><BR>}
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:Rikcuo Akira 回复日期:2003-08-05 11:16:43
<br>内容:"接口函数"是什麼意思?以下函數要改成c++的話,要如何寫呢?<BR>夾檔"my cwebpage adv0520.zip",裡面的"htmldialog.c"要改成C++<BR><BR>// Our IStorage functions that the browser may call<BR>HRESULT STDMETHODCALLTYPE Storage_QueryInterface(IStorage FAR* This, REFIID riid, LPVOID FAR* ppvObj);<BR>HRESULT STDMETHODCALLTYPE Storage_AddRef(IStorage FAR* This);<BR>HRESULT STDMETHODCALLTYPE Storage_Release(IStorage FAR* This);<BR>HRESULT STDMETHODCALLTYPE Storage_CreateStream(IStorage FAR* This, const WCHAR *pwcsName, DWORD grfMode, DWORD reserved1, DWORD reserved2, IStream **ppstm);<BR>HRESULT STDMETHODCALLTYPE Storage_OpenStream(IStorage FAR* This, const WCHAR * pwcsName, void *reserved1, DWORD grfMode, DWORD reserved2, IStream **ppstm);<BR>HRESULT STDMETHODCALLTYPE Storage_CreateStorage(IStorage FAR* This, const WCHAR *pwcsName, DWORD grfMode, DWORD reserved1, DWORD reserved2, IStorage **ppstg);<BR>HRESULT STDMETHODCALLTYPE Storage_OpenStorage(IStorage FAR* This, const WCHAR * pwcsName, IStorage * pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstg);<BR>HRESULT STDMETHODCALLTYPE Storage_CopyTo(IStorage FAR* This, DWORD ciidExclude, IID const *rgiidExclude, SNB snbExclude,IStorage *pstgDest);<BR>HRESULT STDMETHODCALLTYPE Storage_MoveElementTo(IStorage FAR* This, const OLECHAR *pwcsName,IStorage * pstgDest, const OLECHAR *pwcsNewName, DWORD grfFlags);<BR>HRESULT STDMETHODCALLTYPE Storage_Commit(IStorage FAR* This, DWORD grfCommitFlags);<BR>HRESULT STDMETHODCALLTYPE Storage_Revert(IStorage FAR* This);<BR>HRESULT STDMETHODCALLTYPE Storage_EnumElements(IStorage FAR* This, DWORD reserved1, void * reserved2, DWORD reserved3, IEnumSTATSTG ** ppenum);<BR>HRESULT STDMETHODCALLTYPE Storage_DestroyElement(IStorage FAR* This, const OLECHAR *pwcsName);<BR>HRESULT STDMETHODCALLTYPE Storage_RenameElement(IStorage FAR* This, const WCHAR *pwcsOldName, const WCHAR *pwcsNewName);<BR>HRESULT STDMETHODCALLTYPE Storage_SetElementTimes(IStorage FAR* This, const WCHAR *pwcsName, FILETIME const *pctime, FILETIME const *patime, FILETIME const *pmtime);<BR>HRESULT STDMETHODCALLTYPE Storage_SetClass(IStorage FAR* This, REFCLSID clsid);<BR>HRESULT STDMETHODCALLTYPE Storage_SetStateBits(IStorage FAR* This, DWORD grfStateBits, DWORD grfMask);<BR>HRESULT STDMETHODCALLTYPE Storage_Stat(IStorage FAR* This, STATSTG * pstatstg, DWORD grfStatFlag);<BR><BR><BR>// Our IStorage VTable. This is the array of pointers to the above functions in our C<BR>// program that someone may call in order to store some data to disk. We must define a<BR>// particular set of functions that comprise the IStorage set of functions (see above),<BR>// and then stuff pointers to those functions in their respective 'slots' in this table.<BR>// We want the browser to use this VTable with our IStorage structure (object).<BR><BR>IStorageVtbl MyIStorageTable = {Storage_QueryInterface,<BR>Storage_AddRef,<BR>Storage_Release,<BR>Storage_CreateStream,<BR>Storage_OpenStream,<BR>Storage_CreateStorage,<BR>Storage_OpenStorage,<BR>Storage_CopyTo,<BR>Storage_MoveElementTo,<BR>Storage_Commit,<BR>Storage_Revert,<BR>Storage_EnumElements,<BR>Storage_DestroyElement,<BR>Storage_RenameElement,<BR>Storage_SetElementTimes,<BR>Storage_SetClass,<BR>Storage_SetStateBits,<BR>Storage_Stat};<BR><BR>// Our IStorage structure. NOTE: All it contains is a pointer to our IStorageVtbl, so we can easily initialize it<BR>// here instead of doing that programmably.<BR><BR>//IStorage MyIStorage = { &MyIStorageTable };<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -