import "oaidl.idl";
import "ocidl.idl";[
uuid("EBCF2E5F-07AC-40a9-BE77-65BF567A8A47")
] library MyLib
{
[
uuid("BF30B2EF-B113-4b4f-B7C0-92E424C999AB"),
dllname("mynet.dll")
]  module MyNetOp{
[
entry("StartUp")
]
void __stdcall StartUp(long hWnd); [
entry("SignIn")
]
void __stdcall LogIn([in,string,max_is(255)]char *strUserName,
[in,string,max_is(32)]char *strPassword); [
entry("SignOut")
]
void __stdcall LogOut(long nUserId);
[
entry("SendMobileMessage")
]
void __stdcall SendMobileMessage(long nUserId,
long nDestUserId,[in,string,max_is(100)]char *strContent);
[
entry("QueryMessageA")
]
BOOL __stdcall QueryMessage(long dwSeed,
[in,out,ref]struct TClientPacket *pPacket,
[in,out,string,max_is(nTitleLength)]char *strTitle,
long nTitleLength);
[
entry("QueryNotifyA")
]
BOOL __stdcall QueryNotify(long dwSeed,
[in,out,ref]struct TClientPacket *pPacket,
[in,out,string,max_is(nTitleLength)]char *strTitle,
long nTitleLength,
[in,out,string,max_is(nContentLength)]char *strContent,
long nContentLength);
[
entry("GetGroupInfo")
]
BOOL __stdcall GetGroupInfo(long dwSeed,
[in,out,ref]struct TClientPacket *pPacket,
[in,out,string,max_is(nGroupNameLength)]char *strGroupName,
long nGroupNameLength);
[
entry("GetFriendInfo")
]
BOOL __stdcall GetFriendInfo(long dwSeed,
[in,out,ref]struct TClientPacket *pPacket,
[in,out,string,max_is(nNickNameLength)]char *strNickName,
long nNickNameLength,
[in,out,string,max_is(nEmailLength)]char *strEmail,
long nEmailLength);
[
entry("GetCurGroupsCount")
]
int __stdcall GetCurGroupsCount(long dwSeed);
[
entry("GetCurFriendsCount")
]
bool __stdcall GetCurFriendsCount(long dwSeed,
[in,out,ref]long *pnGroupId,
[in,out,ref]long *pnFriendsCount); //消息常量
typedef [public] enum MsgType{
SendToPc,
SendToMobile,
ServerNotify,
UpdateGroups,
UpdateFriends,
CurGroupCount,
CurFriendsCount
}MsgType; typedef [public] struct TClientPacket{
enum MsgType Type;
int dwSenderId;
int dwTitleLength;
int dwContentLength;
byte strDestMobileNumber[20];
}TClientPacket;
}

——————————————————————————————————
上面就是这个DLL的IDL文件,这个DLL是用VC写的,而且是标准的WIN32 DLL,本身没有使用COM,为了在VB中调用方便,特别做了这么一个IDL,很多文章都讲过用这样的方法来方便VB中访问WIN32 API函数,可是当我的VB测试程序访问其中公开出来的方法的时候却出现了异常,一共有两个,分别是:运行是错误'-2147352560(80020010)':
Automation 错误还有一个是运行时错误'91':
未设置对象变量或With block 变量我使用的时候直接从VB中选择引用该IDL产生的类型库,然后直接使用上面定义的方法了,哪位达人知道这是怎么回事啊?

解决方案 »

  1.   

    用VC通过的 一般DLL文件都不会有问题的DLL 是否注册了加入 set ??= new ???
      

  2.   

    现在发现问题所在了,但是还是不太明白为什么会这样,那,上述定义的函数完全可以使用,但是其中的一个初始化函数产生了一个线程,当这个线程退出的时候就会出现这个错误:未设置对象变量或With block 变量使用VC跟踪发现问题出现的时候发生了内存访问异常,就是说有一个函数(不知道是哪一个库里的)访问了内存的0地址,难道说这种库是不能使用线程的么?还是需要某种特殊的处理使之支持自由线程呢?
      

  3.   

    我想也许现在的问题就变成了:在这个DLL内部我使用了自由线程,但是VB端却使用的套间线程,也许,问题应该是该如何平衡这两者之间的关系了:(