如何使用OCX调用DLL? [英] How to call a DLL using an OCX?
本文介绍了如何使用OCX调用DLL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好!
我已经用C ++中的MFC ActiveX向导创建了一个.ocx.现在,我有一个.dll,我想用.ocx调用.dll.那么,怎么办?
非常感谢您吗? )
您还可以使用环境变量LIB. DLL必须在PATH中.
您需要ocx的.tlh(类型库头)文件.
即使用excel:
#include "EXCEL8.tlh" void doanythingwithexcel() { Excel::_ApplicationPtr excelapp; if(S_OK==excelapp.CreateInstance(__TEXT("Excel.Application")) { excelapp->Visible = 1; MessageBox(0,__TEXT("close excel?"),__TEXT("???"),MB_OK); excelapp->Quit(); } }
Hello!
I have created an .ocx with MFC ActiveX Wizard in C++. Now, I have a .dll, I want to call the .dll with the .ocx. So,how to do?
Thank you very much?
解决方案
You can simply #include the header file defining the functions you need and use #pragma comment(lib, "YOUR_PATH\YOUR_LIB.lib")
You also could use the environment variable LIB. The DLL must be in the PATH.
You need the .tlh (Type Library Header) file of your ocx.
i.e. with excel:
#include "EXCEL8.tlh" void doanythingwithexcel() { Excel::_ApplicationPtr excelapp; if(S_OK==excelapp.CreateInstance(__TEXT("Excel.Application")) { excelapp->Visible = 1; MessageBox(0,__TEXT("close excel?"),__TEXT("???"),MB_OK); excelapp->Quit(); } }
这篇关于如何使用OCX调用DLL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文