首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

vb调用vc编写的dll遇到的有关问题

2012-01-22 
vb调用vc编写的dll遇到的问题vb调用vc编写的dll遇到的错误各位大虾,小弟在用vb调用vc编写的dll是遇到了错

vb调用vc编写的dll遇到的问题
vb调用vc编写的dll遇到的错误


各位大虾,小弟在用vb调用vc编写的dll是遇到了错误,渴求帮帮忙:

vc中代码:
dll3.h:
#ifdef   DLL3_EXPORTS
#define   DLL3_API   __declspec(dllexport)
#else
#define   DLL3_API   __declspec(dllimport)
#endif

//   This   class   is   exported   from   the   dll3.dll
class   DLL3_API   CDll3   {
public:
                CDll3(void);
                //   TODO:   add   your   methods   here.
};

extern   DLL3_API   int   nDll3;

DLL3_API   short   fnDll3();/////////////////////////我主要用它

extern   DLL3_API   short   __stdcall   sample();


dll3.cpp代码:
#include   "stdafx.h "
#include   "dll3.h "

BOOL   APIENTRY   DllMain(   HANDLE   hModule,  
                                              DWORD     ul_reason_for_call,  
                                              LPVOID   lpReserved
                                                                                  )
{
        switch   (ul_reason_for_call)
                {
                                case   DLL_PROCESS_ATTACH:
                                case   DLL_THREAD_ATTACH:
                                case   DLL_THREAD_DETACH:
                                case   DLL_PROCESS_DETACH:
                                                break;
        }
        return   TRUE;
}


//   This   is   an   example   of   an   exported   variable
DLL3_API   int   nDll3=0;

//   This   is   an   example   of   an   exported   function.
DLL3_API   short   fnDll3()
{
                return   42;
}

//   This   is   the   constructor   of   a   class   that   has   been   exported.
//   see   dll3.h   for   the   class   definition
CDll3::CDll3()
{  
                return;  
}

DLL3_API   short   __stdcall   sample()
{
return   10;
}

生成的dll3.dll     放入system32目录下;

vb中的代码:



Option   Explicit
Private   Declare   Function   fnDll3   Lib   "dll3.dll "   ()   As   Integer

Private   Sub   Command1_Click()
Dim   i   As   Integer
i   =   12
i   =   fnDll3                     //////////////
MsgBox   i
End   Sub


错误提示:     can 't     find   Dll   entry   point   fnDll3   in   dll3.dll

都愁死我了,恳求大虾们帮帮忙,
期待中......
万分感谢~

[解决办法]
好像给VB的DLL要用什么什么stdcall修饰的吧?
[解决办法]
试试,在工程中加入一个 DLL3.def 文件:
; DLL3.def : Declares the module parameters for the DLL.

LIBRARY "DLL3 "
DESCRIPTION 'DLL3 Windows Dynamic Link Library '

EXPORTS
; Explicit exports can go here

fnDll3@1

然后,重新编译。

热点排行