本文介绍了回调,我根本做不到! (30和250)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个名为Andrew Brock的用户一直在极大地帮助我解决我从DLL调用到EXE的问题 [ ^ ]

但是,我正在尝试实施它.但是,无论我尝试多少,在最坏的情况下我都会不断收到奇怪的错误!因此,我决定打开一个新线程.我非常需要了解回调的操作方式,然后才能继续应用它!

我不明白的是以下内容:
*回调函数应该解决的原始问题是使另一个函数能够调用其无法访问的其他函数,对吗?
funcA()--X-->funcC()
所以
funcA()--funcB()-->funcC()
funcA调用funcB,同时将funcC作为函数指针参数传递.因此,funcA可以调用funcC.
到目前为止,我还可以吗?

我不明白的是:
funcA不知道funcC的地址,对吗? (至少就我而言,这不是因为funcA在DLL中,而funcC在EXE中.).

所以我的问题是funcA在地球上如何传递它不知道的funcC地址??? GGHHHHAAAAAAAAAAAA !!!!!!这使我下意识....... !!!!!!!!!

A user named Andrew Brock has been helping me out immensely with a problem I am having with calling from DLLs to EXEs Calling to an EXE function from inside a DLL[^]

However, I am trying to implement it. But, no matter how much I try, I keep getting strange errors in the worst timings! So, I decided to open a new thread. I badly need to understand how callback operates before I can go ahead and apply it!

What I cannot understand is the following:
* The original problem that callback functions are supposed to fix enabling another function to call some other function that is out of its reach, right?
funcA()--X-->funcC()
so
funcA()--funcB()-->funcC()
funcA calls to funcB while passing funcC as a function pointer parameter. Hence, funcA can call to funcC.
Am I OK so far?

What I cannot understand is this:
funcA doesn''t know the address of funcC, right? (at least in my case it doesn''t since funcA is in the DLL and funcC is in the EXE.).

So my question is how on earth can funcA pass the address of funcC that it doesn''t know of??? GGHHHHAAAAAAAAAAAA!!!! this is bending my mind.......!!!!!!!

推荐答案

void funcA(funcB_callback funcB, ...)
{
  funcB(...);
}



这样就可以了,因为在exe和dll中都知道函数定义(或签名),并且您在运行时为dll提供了运行时函数指针,以便dll可以实际调用它.

就像使用EnumWindows winapi一样,您还为它提供了一个为每个窗口调用的回调函数指针.
http://msdn.microsoft.com/en-us/library/ms633497%28v = vs.85%29.aspx [ ^ ]

祝你好运!



So it can work because the function definition (or signature) is known in both exe and dll and you provide the dll with the runtime function pointer at runtime so the dll can actually call it.

It is just like using the EnumWindows winapi where you also provide it a callback function pointer that is called for each window.
http://msdn.microsoft.com/en-us/library/ms633497%28v=vs.85%29.aspx[^]

Good luck!



这篇关于回调,我根本做不到! (30和250)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 19:40