本文介绍了为什么需要使用"WINAPI *"?用于在DLL中声明函数的函数指针的语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C ++控制台应用程序& DLL.在C ++应用程序中,我看到以下代码片段::

I have a C++ console application & a DLL. In the C++ application I see the following snippet ::

typedef DWORD (WINAPI* functABC)(unsigned long*);

functABC functABC111;
HMODULE handleDLL = LOadLibrary("a.DLL");
functABC111 = (functABC)GetProcAddress(handleDLL,"function_1");

从高层次上来说,我了解到我们正在a.DLL"function_1()"中获得指向该函数的函数指针.

At a high level I understand that we are getting the function pointer to the function in a.DLL "function_1()".

但是要了解上面片段中的第1行第2行:

But want to understand the 1st 2 lines in the above snippet ::

typedef DWORD (WINAPI* functABC)(unsigned long*);
functABC functABC111;

2个问题::1)名称"functABC"仅仅是随机函数指针名称吗?
2)从技术上讲,我们在这两行中都在做什么.声明函数指针.
3)为什么我们需要在第一行的函数指针声明中使用WINAPI *.

2 questions ::1) Is the name "functABC" just a random function pointer name?
2) What are we technically doing in these 2 lines. Declaring function pointer.
3) Why do we need to use WINAPI* in the function pointer declaration in 1st line.

先谢谢.

推荐答案

  1. ' functABC '是一个函数的typedef,该函数以无符号长指针为参数返回 DWORD

  1. 'functABC' is a typedef to a function returning a DWORD taking an unsigned long pointer as a parameter

第一行定义一个typedef,第二行使用它创建一个函数指针

First lines defines a typedef and second one creates a function pointer using it

' WINAPI '是一个宏,通常会扩展为' __ stdcall ',这是Microsoft用于导出的调用约定来自. DLL

'WINAPI' is a macro that's usually expanded to '__stdcall' which is the calling convention used by Microsoft to export functions from a .DLL

这篇关于为什么需要使用"WINAPI *"?用于在DLL中声明函数的函数指针的语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 06:51