制作ATL COM组件时,引用ADO 2.6的问题

sproll 2003-10-15 05:41:23
请问大虾,小弟想制作一个ATL COM组件,其中包含一个ClassSample类,在该类中有一个接口DBConnect方法,现要求DBConnect方法在VB的object browser显示的声明如下:

Function DBConnect(DataInitString As String, [lErrNo As Long], [strErrDes As String]) As Connection

于是小弟建了一个ATL项目,并在stdafx.h中添加了:

#import "c:\Program Files\Common Files\System\ADO\msado15.dll" \
no_namespace rename("EOF", "EndOfFile")

然后又添加了一个ATL对象ClassSample,在该对象中添加DBConnect方法:

[id(1), helpstring("方法SampleMethod")] HRESULT SampleMethod( [in] BSTR DataInitString, [in, out, optional] long* lErrNo, [in, out, optional] BSTR* strErrDes, [out, retval] _Connection ** );

但编译的时候总是说_Connection类型未声明:

unresolved type declaration : _Connection [ Parameter of Procedure 'DBConnect' ( Interface 'IClassSample' ) ]

哪位大哥能给个解决方法?
...全文
36 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
sproll 2003-10-16
  • 打赏
  • 举报
回复
血血楼上的大虾,偶去试试。
flyingjust 2003-10-16
  • 打赏
  • 举报
回复
在 library XXXLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");

importlib("C:\Program Files\Common Files\System\ADO\msado15.dll");
sproll 2003-10-16
  • 打赏
  • 举报
回复
我已经搞定了,哈哈哈,跪谢各位大虾!
哈哈哈哈,害得我研究了两天……
sproll 2003-10-16
  • 打赏
  • 举报
回复
现在我把Importlib加在IDL文件中了,还是提示同样错误。哪位大哥帮帮忙?


// ATLS.idl : IDL source for ATLS.dll
//

// This file will be processed by the MIDL tool to
// produce the type library (ATLS.tlb) and marshalling code.

import "oaidl.idl";
import "ocidl.idl";


[
object,
uuid(630D9AA2-A5A3-4C7A-A971-1D0C8AC55DD0),
dual,
helpstring("ISampleClass Interface"),
pointer_default(unique)
]
interface ISampleClass : IDispatch
{
[id(1), helpstring("method MethodSample")] HRESULT MethodSample(
[in] BSTR strConnectionString,
[in, out, optional] long* lngErrNo,
[in, out, optional] BSTR* strErrDes,
[out, retval] _Connection** );
};

[
uuid(D6A66847-30A3-4008-8459-F011134497C6),
version(1.0),
helpstring("ATLS 1.0 Type Library")
]
library ATLSLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
importlib("c:\Program Files\Common Files\System\ADO\msado15.dll");
//在这儿加了上,可是还是不行
[
uuid(BA3FB017-A780-4F3F-A841-77E36587F4A7),
helpstring("SampleClass Class")
]
coclass SampleClass
{
[default] interface ISampleClass;
};
};
xiaohyy 2003-10-15
  • 打赏
  • 举报
回复
_ConnectionPtr
天限天空 2003-10-15
  • 打赏
  • 举报
回复
在 library XXXLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
下引入
import "xxx.dll"
ba把 接口定义也放在这后面

3,245

社区成员

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

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