本文介绍了从c ++线程调用VB6函数指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从线程调用指针。

这是我的代码:



myDll.dll c ++:

I'm trying to call from a thread to a pointer.
Here is my code:

myDll.dll c++ :

long cbAddrAsync;
void _asyncer(void* data)
{
        typedef void (__stdcall *FUNCPTR)();
    FUNCPTR vbFunc;
    vbFunc = (FUNCPTR)cbAddrAsync;
    vbFunc();
}
extern "C" __declspec(dllexport) void async(long addr)
{
    cbAddrAsync = addr;
    HANDLE hHandle = (HANDLE)_beginthread(_asyncer,0,NULL);
}





用vb6跟这个extern打电话:

在Module1中:



calling to this extern with vb6:
In Module1:

Declare Sub async Lib "myDll.dll" (ByVal addr As Long)
Sub onAsync()
MsgBox "ASYNC"
End Sub



Form1:




In Form1:

Private Sub Command_Click()
Call async(AddressOf Module1.onAsync)
End Sub



,问题发生在DLL中:

Project1.exe中0x734f9232处的未处理异常:0xC0000005:访问冲突读取位置0x00000076。

in vbFunc();



如何解决?

谢谢。



when i click at command button , The problem occurs in dll:
Unhandled exception at 0x734f9232 in Project1.exe: 0xC0000005: Access violation reading location 0x00000076.
in vbFunc();

How can I fix it?
Thanks.

推荐答案


这篇关于从c ++线程调用VB6函数指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 21:07