OLD的module中的函数在VC中如何调用?

LeeZi 2003-08-13 12:05:26
用OLE view打开WINNT\SYSTEM32\stdole2.tlb可以看到有一个module块,我想知道其中的函数在VC中如何调用?

VB中直接可以stdole.LoadPicture(...),但是在VC中呢?
...全文
57 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
LeeZi 2003-08-30
  • 打赏
  • 举报
回复
嘿,我知道了。可以通过ITypeInfo上的方法去调用。
再次感谢blueblood7()对我的启发。
LeeZi 2003-08-29
  • 打赏
  • 举报
回复
blueblood7():
谢谢你,你这段代码帮我解决一半问题。可是下面如果我要调用的话要怎么去做呢?

难道再根据DLL去LOAD?应该不会是这样的吧?
LeeZi 2003-08-22
  • 打赏
  • 举报
回复
up
wujpbb7 2003-08-22
  • 打赏
  • 举报
回复
module 里的函数是调用 dll 中的,此例为 oleaut32.dll。
由以下代码可以看出,它调的是 OleLoadPictureFileEx 和 OleSavePicture。
ITypeLib* pTypeLib = NULL;
ITypeInfo* pTypeInfo = NULL;
FUNCDESC* pFuncDesc;
MEMBERID idMember;
HRESULT hr;
INVOKEKIND invKind;
BSTR bstrDllName, bstrFuncName;
WORD dwOrdinal;
hr = CoInitialize( NULL );
if( SUCCEEDED(hr) )
{
hr = LoadTypeLib( L"stdole2.tlb", &pTypeLib );
if( SUCCEEDED(hr) )
{
TYPEATTR* ptypeaddr = NULL;
UINT uCount = pTypeLib->GetTypeInfoCount();
for(UINT i=0; i<uCount; i++)
{
pTypeLib->GetTypeInfo( i, &pTypeInfo );
pTypeInfo->GetTypeAttr( &ptypeaddr );
if( ptypeaddr->typekind == TKIND_MODULE

)
{
for( int i=0;

i<ptypeaddr->cFuncs; i++)
{


pTypeInfo->GetFuncDesc(i, (FUNCDESC**)&pFuncDesc);
idMember =

pFuncDesc->memid;
invKind =

pFuncDesc->invkind;
if( S_OK ==

pTypeInfo->GetDllEntry( idMember, invKind, &bstrDllName,


&bstrFuncName, &dwOrdinal ) )
{


SysFreeString(bstrDllName);


SysFreeString(bstrFuncName);
}





pTypeInfo->ReleaseFuncDesc(pFuncDesc);
}
}
pTypeInfo->ReleaseTypeAttr( ptypeaddr

);
}
}
CoUninitialize();
}


NewFree 2003-08-21
  • 打赏
  • 举报
回复
gz
LeeZi 2003-08-21
  • 打赏
  • 举报
回复
up
LeeZi 2003-08-20
  • 打赏
  • 举报
回复
to zzyx(菜农):
我知道你说的这些函数,我只是想知道如何调用DLL中的函数?
因为VB可以调用,所以我相信VC应该也有办法调用的,只是如何去调呢?你不想知道VB又是如何实现调用这个函数的吗?

其实更抽象一点,问题是:
如何调用在ODL中moudle中描述的那些函数?
我只是怕有些人还不知道ODL中还有module这个东东。(我也是才知道的)
zzyx 2003-08-15
  • 打赏
  • 举报
回复
以Ole开头的还有一大堆函数,看起来功能很强。

……俺也没有用过,只是查msdn发现地
zzyx 2003-08-15
  • 打赏
  • 举报
回复
哈哈,这个200分好像比较容易得呀!
快给分吧,俺还差一点点分就长红毛了!

OleLoadPicture
Creates a new picture object and initializes it from the contents of a stream. This is equivalent to calling OleCreatePictureIndirect(NULL, ...) followed by IPersistStream::Load.

STDAPI OleLoadPicture(

IStream * pStream,

//Pointer to the stream that contains picture's data

LONG lSize, //Number of bytes read from the stream

BOOL fRunmode,

//The opposite of the initial value of the picture's

// property

REFIID riid, //Reference to the identifier of the interface

// describing the type of interface pointer to return

VOID ppvObj //Address of output variable that receives interface

// pointer requested in riid

);

Parameters
pStream
[in] Pointer to the stream that contains the picture's data.

lSize

[in] Number of bytes that should be read from the stream, or zero if the entire stream should be read.

fRunmode

[in] The opposite of the initial value of the KeepOriginalFormat property. If TRUE, KeepOriginalFormat is set to FALSE and vice-versa.

riid

[in] Reference to the identifier of the interface describing the type of interface pointer to return in ppvObj.

ppvObj

[out] Address of pointer variable that receives the interface pointer requested in riid. Upon successful return, *ppvObj contains the requested interface pointer on the storage of the object identified by the moniker. If *ppvObj is non-NULL, this function calls IUnknown::AddRef on the interface; it is the caller's responsibility to call IUnknown::Release. If an error occurs, *ppvObj is set to NULL.

Return Values
This function supports the standard return values E_OUTOFMEMORY and E_UNEXPECTED, as well as the following:
S_OK

The picture was created successfully.

E_POINTER

The address in pStream or ppvObj is not valid. For example, either may be NULL.

E_NOINTERFACE

The object does not support the interface specified in riid.

Remarks
The stream must be in BMP (bitmap), WMF (metafile), or ICO (icon) format. A picture object created using OleLoadPicture always has ownership of its internal resources (fOwn==TRUE is implied).

3,245

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧