十万火急!高分送高手!如何在WIN32 application 中,调用ACTIVEX DLL

qzhong1028 2000-08-14 02:03:00
我在一个WIN32 的程序中需要调用我用VB写的activex dll,该如何调用,最好给些代码(我以前调用都是通过MFC的 class wizard导出DLL 中的类来,但是在WIN32 的APPLICATION 中,不支持MFC 我该怎么办?)
...全文
311 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
teddyboy 2000-09-08
  • 打赏
  • 举报
回复
在此表示非常关注!
ddm95 2000-09-05
  • 打赏
  • 举报
回复
通过Visual Studio 带的Ole/Com Viewer 工具查看该DLL,生成三个文件,一个.idl, 一个.h
,一个.c文件,看到这三个文件的内容,你就知道该怎么做了!
zcheny 2000-08-26
  • 打赏
  • 举报
回复
在VC中使用COM对象,最简单直接的办法是使用智能指针,可以在CPP文件中加入
#import "C:\yourdllpath\youdll.dll(或youdll.tlb)" no_namespace
然后import关键字会自动生成两个头文件youdll.tlh,youdll.tli,其中定义了智能指针和封装类,你可以用下面方法声明一个智能指针:
YourInterfaceptr ptrMyInterface;

可以用该指针访问COM接口的方法,且不用关心接口的引用计数问题,因为智能指针已经封装好了。记住千万不要调用下面语句:
ptrMyInterface->Release;
zzh 2000-08-19
  • 打赏
  • 举报
回复
要把你的DLL用import语句引入
qzhong1028 2000-08-18
  • 打赏
  • 举报
回复
Thank your answer,yes,i just start to study com.
but i do as you told me,and i meet some questions
1.i have only .tlb file how can i get .idl file?
2.In my project,i do as follows,but it's wrong!
import "mycom.tlb"
....
mycominterface* pI;
Complier tells me not declare mycominterface.
why?
can you give me some code?
xlzhou 2000-08-18
  • 打赏
  • 举报
回复
I believe you don't know COM and VC++.

The VB activeX components are all STA,

call CoInitializeEx to create a appartment

call CoCreateInstance to create component and get IUnknow interface,

call obj->QueryInterface to query other interfaces,

because VB components support both IDsipatch and VTBL

you can invoke the method by calling the IDispatch::Invoke

or directly call the VTBL functions.

to create the encapsulte classes please use MIDL.exe

to create smart pointer please #import the type library

... ... ... ... ... ... ...

you should learn the COM basic!!!

3,245

社区成员

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

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