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产生的类型库,然后直接使用上面定义的方法了,哪位达人知道这是怎么回事啊?
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产生的类型库,然后直接使用上面定义的方法了,哪位达人知道这是怎么回事啊?
UMYNET_API int __stdcall SignIn(char *strUserName,char strPassword[32]);
UMYNET_API void __stdcall SignOut(void);
UMYNET_API BOOL __stdcall RecvData(void);
UMYNET_API BOOL __stdcall Scan(void);
UMYNET_API void __stdcall SendMobileMessage(int nUserId,int nDestUserId,char
*strContent);
UMYNET_API BOOL __stdcall QueryMessageA(DWORD dwSeed,TClientPacket
*pPacket,char *strTitle,int nTitleLength);
UMYNET_API BOOL __stdcall QueryNotifyA(DWORD dwSeed,TClientPacket
*pPacket,char *strTitle,int nTitleLength, char *strContent,int nContentLength);
UMYNET_API BOOL __stdcall GetGroupInfo(DWORD dwSeed,TClientPacket
*pPacket,char *strGroupName,int nGroupNameLength);
UMYNET_API BOOL __stdcall GetFriendInfo(DWORD dwSeed,TClientPacket
*pPacket,char *strNickName,int nNickNameLength, char *strEmail,int nEmailLength);
UMYNET_API int __stdcall GetCurGroupsCount(DWORD dwSeed);
UMYNET_API BOOL __stdcall GetCurFriendsCount(DWORD dwSeed,int *pnGroupId,int
*pnFriendsCount);
UMYNET_API int __stdcall GetTimeOutPacket(DWORD dwSeed,char *strContent,int
nContentLength);
UMYNET_API int __stdcall GetSendFinishedPacket(DWORD dwSeed,char
*strContent,int nContentLength);————————————————————这是导出的函数的声明,其中UMYNET_API被定义为extern"C"——————————————————————LIBRARY UmyNetEXPORTS StartUp
SignIn
SignOut
RecvData
Scan
SendMobileMessage
QueryMessageA
QueryNotifyA
GetGroupInfo
GetFriendInfo
GetCurGroupsCount
GetCurFriendsCount
GetTimeOutPacket
GetSendFinishedPacket——————————————————————
这是导出文件——————————————————————import "oaidl.idl";
import "ocidl.idl";[
uuid("A5E2E8CD-633B-4ced-95CA-64A6093E7877")
] library UmyNetTool
{
[
uuid("BC03F7CD-8024-4a5d-89A5-A1E40C193E89"),
dllname("umynet.dll"),
version(1.0)
] module UmyOp{
[
entry("StartUp")
]
void _stdcall StartUp(long hWnd); [
entry("SignIn")
]
long _stdcall LogIn([in]LPCWSTR strUserName,[in]LPCWSTR
strPassword); [
entry("SignOut")
]
void _stdcall LogOut(void); [
entry("RecvData")
]
long __stdcall RecvData(void); [
entry("Scan")
]
long __stdcall Scan(void); [
entry("SendMobileMessage")
]
void _stdcall SendMobileMessage(long nUserId,long
nDestUserId,[in,string,max_is(100)]char *strContent); [
entry("QueryMessageA")
]
long _stdcall QueryMessage(long dwSeed,[in,out,ref]struct
TClientPacket *pPacket,
[in]LPCWSTR strTitle,long nTitleLength);
[
entry("QueryNotifyA")
]
long _stdcall QueryNotify(long dwSeed,[in,out,ref]struct
TClientPacket *pPacket, [in]LPCWSTR strTitle,long
nTitleLength,[in]LPCWSTR strContent,long nContentLength);
[
entry("GetGroupInfo")
]
long _stdcall GetGroupInfo(long dwSeed,[in,out,ref]struct
TClientPacket *pPacket,[in]LPCWSTR strGroupName,long
nGroupNameLength);
[
entry("GetFriendInfo")
]
long _stdcall GetFriendInfo(long dwSeed,[in,out,ref]struct
TClientPacket *pPacket,[in]LPCWSTR strNickName,long
nNickNameLength,[in]LPCWSTR strEmail,long nEmailLength); [
entry("GetTimeOutPacket")
]
long __stdcall GetTimeOutPacket([in]long dwSeed,[in,out]
LPCWSTR strContent,long nContentLength); [
entry("GetSendFinishedPacket")
]
long __stdcall GetSendFinishedPacket([in]long dwSeed,
[in,out]LPCWSTR strContent,long nContentLength); //消息常量
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];
int dwCurGroupCount;
int dwCurFriendsCount;
int dwUserId;
int dwNickNameLength;
int dwEmailLength;
int dwSex;
int bIsMember;
int dwGroupId;
int dwGroupType;
int dwParentGroupId;
int dwGroupOrder;
int dwGroupNameLength;
}TClientPacket;
}
}
————————————————————
这就是那个IDL了问题就是,当生成TLB之后,VB可以识别出IDL中的入口,但是运行的时候就抱错,说没有找到入口在DLL中,这是怎么回事?