GetProcAddress

Syntax

FARPROC GetProcAddress(hModule,lpProcName)

This function retrieves the memory address of the function whose name is pointed to by the lpProcName parameter. The GetProcAddress function searches for the function in the module specified by the hModule parameter, or in the current module if hModule is NULL. The function must be an exported function; the module's definition file must contain an appropriate EXPORTS line for the function.

Parameter Type/Description  

hModule HANDLE Identifies the library module that contains the function.  
lpProcName LPSTR Points to the function name, or contains the ordinal value of the function. If it is an ordinal value, the value must be in the low-order word and zero must be in the high-order word. The string must be a null-terminated character string.  

Return Value

The return value points to the function's entry point if the function is successful. Otherwise, it is NULL.

If the lpProcName parameter is an ordinal value and a function with the specified ordinal does not exist in the module, GetProcAddress can still return a non-NULL value. In cases where the function may not exist, specify the function by name rather than ordinal value.

Comments

Only use GetProcAddress to retrieve addresses of exported functions that belong to library modules. The MakeProcInstance function can be used to access functions within different instances of the current module.

The spelling of the function name (pointed to by lpProcName) must be identical to the spelling as it appears in the source library's definition (.DEF) file. The function can be renamed in the definition file.