• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >vc/mfc > OLD的module中的函数在VC中如何调用?

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

作者:佚名 字体:[增加 减小] 来源:互联网 时间:2017-06-04

佚名通过本文主要向大家介绍了module 6 old and new,vc old,vc getmodulefilename,module函数,linux 加载module函数等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: OLD的module中的函数在VC中如何调用?
描述:

用OLE view打开WINNT\SYSTEM32\stdole2.tlb可以看到有一个module块,我想知道其中的函数在VC中如何调用?
VB中直接可以stdole.LoadPicture(...),但是在VC中呢?


解决方案1:

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();
}

解决方案2:

哈哈,这个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). 


分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

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

相关文章

  • 2017-06-04 activex本地显示问题
  • 2017-06-04 怎么开发一个ActiveX签名控件
  • 2017-06-04 怎么为COM增加事件
  • 2017-06-04 有没有在广州的写Com的高手,有很难的问题想当面向你请教啊(呵呵,有报酬啊)
  • 2017-06-04 继续刚才实现insertActiveXControls对话框的提问
  • 2017-06-04 如何将Activexocx转为Activexexe
  • 2017-06-05 谁知道winnt中进程"systemidleprocess"是什么?
  • 2017-06-05 socket急!!!!
  • 2017-06-05 关于vc++中的console控制问题--调用system时怎样隐藏ms-dos窗口?
  • 2017-06-04 如何获得输入得BSTR字符串得值?

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • 请问大家,DLL能否向加载它的程序发送消息或其它措施,目的是要让主程序进行某一操作,我想在DLL中实现通知主程序的功能
    • 大家帮我看看这个方法的代码,参数总是不能返回正确的值?
    • ####想要看别人实现的DLL文件有什么办法???#########
    • vcexe文件转activex控件
    • 如何结束一个线程
    • vs2008下串口初始化的问题
    • 各位大哥,在VC++中有没有制作动态变化曲线的控件啊??
    • 请教一下,colorref,ole_color,long三种类型之间的转换方法?特别是colorreftolong
    • 如何生成一个COM组件的多个对象
    • directx和visualstudio是什么关系?

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有