网站首页  词典首页

请输入您要查询的函数:

 

术语 getprocaddress
释义 GetProcAddress
语法:
C++
FARPROC WINAPI GetProcAddress(
__in HMODULE hModule,
__in LPCSTR lpProcName
);
GetProcAddress函数
检索报告从指定的动态导出函数或变量链接库(DLL)。
参数
hModule [in]
句柄的DLL模块包含函数或变量。的LoadLibrary,LoadLibraryEx,或GetModuleHandle函数返回此句柄。
GetProcAddress函数不检索从被装用LOAD_LIBRARY_AS_DATAFILE标志模块地址。有关更多信息,请参阅LoadLibraryEx。
lpProcName [in]
函数或变量的名称,或函数的序号值。如果这个参数是一个序数值,它必须在低位字,在高位字必须为零。
返回值
如果函数成功,返回值是导出的函数或变量的地址。
如果函数失败,返回值为NULL。为了获得更多错误信息,调用GetLastError。
备注
拼写和函数名称的大小写指向lpProcName必须是相同的源DLL的模块定义该EXPORTS语句(。def)文件。导出的函数的名称可能不同的名称使用时,您的代码中调用这些函数。这种差异是隐藏在SDK头文件使用的宏。有关更多信息,请参阅函数原型公约。
该lpProcName参数可以指定一个识别序号值与出口相关的声明函数的DLL函数。调用GetProcAddress验证指定的序号范围在1到最高序的。def文件中导出的值。该函数然后使用顺序为指标,来读取函数表中的函数的地址。
如果。def文件不连续的职能数量从1到N(其中N是导出的函数的数量),可能会出现错误时调用GetProcAddress返回无效,非空的地址,即使是没有功能的指定序。
如果该函数可能不存在的DLL模块,例如,如果该函数仅适用于Windows Vista,但应用程序可能运行在Windows XP的指定名称的功能,而不是由序价值和设计应用程序以处理案件时,不可用的功能,如下面的代码片段所示。

typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
// Call GetNativeSystemInfo if supported or GetSystemInfo otherwise.
PGNSI pGNSI;
SYSTEM_INFO si;
ZeroMemory(&si, sizeof(SYSTEM_INFO));

pGNSI = (PGNSI) GetProcAddress(
GetModuleHandle(TEXT("kernel32.dll")),
"GetNativeSystemInfo");
if(NULL != pGNSI)
pGNSI(&si);
else GetSystemInfo(&si);

对于完整的示例包含此代码片段,看到使用的系统版本。
实例
有关示例,请参阅使用运行时动态链接。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
动态链接库函数
FreeLibrary
GetModuleHandle
调用LoadLibrary
运行时动态链接
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==GetProcAddress Function
Retrieves the address of an exported function or variable from the specified dynamic-link library (DLL).
Syntax
C++
FARPROC WINAPI GetProcAddress(
__in HMODULE hModule,
__in LPCSTR lpProcName
);
Parameters
hModule [in]
A handle to the DLL module that contains the function or variable. The LoadLibrary , LoadLibraryEx , or GetModuleHandle function returns this handle.
The GetProcAddress function does not retrieve addresses from modules that were loaded using the LOAD_LIBRARY_AS_DATAFILE flag. For more information, see LoadLibraryEx.
lpProcName [in]
The function or variable name, or the function's ordinal value. If this parameter is an ordinal value, it must be in the low-order word; the high-order word must be zero.
Return Value
If the function succeeds, the return value is the address of the exported function or variable.
If the function fails, the return value is NULL. To get extended error information, call GetLastError .
Remarks
The spelling and case of a function name pointed to by lpProcName must be identical to that in the EXPORTS statement of the source DLL's module-definition (.def) file. The exported names of functions may differ from the names you use when calling these functions in your code. This difference is hidden by macros used in the SDK header files. For more information, see Conventions for Function Prototypes .
The lpProcName parameter can identify the DLL function by specifying an ordinal value associated with the function in the EXPORTS statement. GetProcAddress verifies that the specified ordinal is in the range 1 through the highest ordinal value exported in the .def file. The function then uses the ordinal as an index to read the function's address from a function table.
If the .def file does not number the functions consecutively from 1 to N (where N is the number of exported functions), an error can occur where GetProcAddress returns an invalid, non-NULL address, even though there is no function with the specified ordinal.
If the function might not exist in the DLL module—for example, if the function is available only on Windows Vista but the application might be running on Windows XP—specify the function by name rather than by ordinal value and design your application to handle the case when the function is not available, as shown in the following code fragment.

typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
// Call GetNativeSystemInfo if supported or GetSystemInfo otherwise.
PGNSI pGNSI;
SYSTEM_INFO si;
ZeroMemory(&si, sizeof(SYSTEM_INFO));

pGNSI = (PGNSI) GetProcAddress(
GetModuleHandle(TEXT("kernel32.dll")),
"GetNativeSystemInfo");
if(NULL != pGNSI)
pGNSI(&si);
else GetSystemInfo(&si);
For the complete example that contains this code fragment, see Getting the System Version .
Examples
For an example, see Using Run-Time Dynamic Linking .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
Dynamic-Link Library Functions
FreeLibrary
GetModuleHandle
LoadLibrary
Run-Time Dynamic Linking
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms683212(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:25:13