如何解决DLL函数调用问题
我有几个关于 DLL 的查询,
1)如果我在运行时加载 DLL,我猜 DLL 将位于单独的线程中,对吗?
2)如果我调用DLL中存在的函数,并且该函数需要很长时间才能返回值,那么我如何让我的应用程序线程等待DLL的函数返回值。
我该如何解决第二个问题
i have couple of query's with respect to DLL,
1)If i load the DLL in run time, i guess DLL will be in separate thread right?
2)If i call a function present in DLL, and that function takes much time to return the value then how can i make my application thread to wait till the DLL's function return value.
How can i solve the second problem
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你的假设是不正确的。
如果加载 DLL,然后调用其函数之一,则该调用是同步进行的,就像任何其他函数调用一样。
绝对没有理由在另一个线程中加载 DLL。当然,您可以这样做,但这不是默认设置。
Your assumption is incorrect.
If you load a DLL, and then call one of its functions, the call is made synchronously, just like any other function call.
There is absolutely no reason why the DLL should be loaded in another thread. You may do it, of course, but this is not the default.
1) 不。dll 只是代码。 DLL 中的代码将在您创建的任何线程的上下文中调用。 *
2) 因此,您的应用程序将等待 dll 的函数完成。
1) No. The dll is just code. The code in the dll is called in the context of whatever threads you create. *
2) As a result, your application will wait for the dll's function to complete.
你用的是qt线程吗?否则我无法理解为什么你会使用“qt”标签。
至于你的问题,在我看来,你必须创建另一个线程来调用 DLL 中包含的函数。
当该线程退出时,您可以假设您拥有该函数的结果。
Are you using qt threads? Otherwise I cannot understand why you would use the "qt" tag.
As for your problems it seems to me that you have to create another thread which will call the function contained in the DLL.
When this thread exits than you can assume you have the function's result.
DLL_THREAD_ATTACH
。DLL_THREAD_ATTACH
too.