当前位置:编程学习 > VB >>

VB6.0调用Visual Studio 2005编写的静态连接MFC的DLL,导致崩溃!!

在C++中声明全局函数extern"C" _declspec(dllexport) void imagedeal(CString)

VB中这样声明

Private Declare Function imagedeal Lib "d:\VB\mydll.dll" (ByVal filename As String)

调用语句:
Call imagedeal(FilePath) FilePath是STRING型
结果VB崩溃,弹出下面的对话框



Debug Assertion Failed!

Progran: C:\Program Files\Microsoft Visual Studio\VB98\VB6.EXE
File: c:\program files\microsoft visual studio 8\vc\atlmfc\include\atlsimpstr.h
Line:107
Expression:nRefs!=0

for information..............


到底是怎么回事啊?!!!!! --------------------编程问答-------------------- 把declspec改成stdcall试试

--------------------编程问答-------------------- 问题依旧 --------------------编程问答-------------------- 给个示例:
Const test_dllPath As String = "E:\vbExample\050802\Calling cdecl dll exports\cdecl.dll"
Private Declare Sub Msg Lib "E:\vbExample\050802\Calling cdecl dll exports\cdecl.dll" (ByVal Msg As String)

'--> if you dont have VC to compile the test dll you can find it
'      in here: http://sandsprite.com/CodeStuff/vb_cdecl.zip

'---------------------------------------------------------------------------------


Private Declare Sub DebugBreak Lib "kernel32" ()
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)

'same as default CallWindowProc except
'param 1 is now "ByRef lpBytes As Any"
'or you can use the default like this: CallWindowProc( Varptr( asmBytes(0) ) ,
Private Declare Function CallAsm Lib "user32" _
                Alias "CallWindowProcA" ( _
                    ByRef lpBytes As Any, _
                    ByVal hWnd As Long, _
                    ByVal Msg As Long, _
                    ByVal wParam As Long, _
                    ByVal lParam As Long _
                ) As Long
--------------------编程问答-------------------- 大哥,你的参数是CString啊,这是二进制调用,你以为会象VC编译器那样自动转换啊。
把你的参数改成LPCTSTR,然后用def文件把这个函数导出。vb是没有办法调用不规则的dll的。
--------------------编程问答-------------------- 参数CString产生的问题
同意楼上所说
补充:VB ,  基础类
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,