本文将介绍在vs2008 中C++ 调用vb6.0 生成的activex dll。具体的源代码可以从以下链接下载:http://download.csdn.net/detail/xsjm206/4092111
第一步:vb6.0制作的Activex DLL,发布为PRO.dll,并手动注册该dll文件(regsvr32 )。
第二步:vs2008,C++ 制作控制台程序调用PRO.dll,main 函数中的代码如下:
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include<atlstr.h>
#include <iostream>
#include <string>
#include <string.h>
#include <comdef.h>
using namespace std;
#import "C:\PRO.dll" no_namespace //导入activex dll,"C:\PRO.dll"是dll的路径,也可以放在执行目录下或C:\windows\system32下
int _tmain(int argc, _TCHAR* argv[])
{
short Ret;
CString strDir("D:\\NonSave\\aa");//斜杠需要转义
BSTR strC =strDir.AllocSysString();
CString strFile("D:\\NonSave\\a.txt");
BSTR str