访问CPP文件中的Dll函数 [英] Access Dll functions in CPP file

查看:63
本文介绍了访问CPP文件中的Dll函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!

这里我粘贴了一些cpp文件的代码片段。

Hello!
Here I am paste my some code snippets of cpp file.

typedef int(*pFunctionPointer2)(int,HANDLE);
typedef int(*pFunctionPointer3)(int,int,char*,HANDLE);
typedef int(*pFunctionPointer4)(FILE*,int,int,HANDLE);
typedef bool(*pFunctionPointer5)(HANDLE);

pFunctionPointer2 pFn2 = NULL;
pFunctionPointer3 pFn3 = NULL;
pFunctionPointer4 pFn4 = NULL;
pFunctionPointer5 pFn5 = NULL;



例如


for e.g.

pFn2 = (pFunctionPointer2)GetProcAddress(hLib,"ADDNumber");





我在其中使用了dll函数,但是基于MFC对话的应用程序有不同的事件。



因此对于每个事件,所有typedef函数都应该调用,是否有在一个函数中声明并立即调用的任何方法?



in which I used dll function, but there are different events of MFC dialogue based application.

So for each event all typedef functions should have to call, is there any way to declare in one function and call at once?

推荐答案

总之,没有定义,转换和分配所有方法地址的快捷方式。



解决这个问题的唯一方法是链接到有问题的dll,而不是使用LoadLibrary()/ GetProcAddress()。
In a word, no there is no shortcut to defining, casting and assigning all of the method addresses.

The only way to get around this is to link to the dll in question rather than using LoadLibrary()/GetProcAddress().


您可以使用所有事件的主要焦点:

You could use the "main focus" of all "events":
// exported by DLL
// BOOL DllCheckMsg(MSG*);

// your.cpp
/*virtual*/ BOOL CYourDlgApp::PreTranslateMessage(MSG* pMsg)
{
  (*m_pfnDllCheckMsg)(pMsg);
    
  CWinApp(Ex)::PreTranslateMessage(pMsg);
}



但是,沟通的目标对我来说并不明确......:)


However, the goal of the communication is not clear for me... :)


这篇关于访问CPP文件中的Dll函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆