GetProcAddress

  FARPROC GetProcAddress(hModule, lpszProc)    
  HANDLE hModule; /* identifies the DLL module */
  LPCSTR lpszProc; /* identifies the function */

The GetProcAddress function returns the address of the specified exported DLL function.

Parameters

hModule

Identifies the DLL module that contains the function. The LoadLibrary function returns this handle.

lpszProc

Points to a null-terminated string containing the function name, or specifies the ordinal value of the function. If it is an ordinal value, the value must be in the low word and the high word must be zero.

Return Value

The return value is the address of the function's entry point if the function is successful. Otherwise, it is NULL. Use the GetLastError function to obtain extended error information.

Comments

Use the GetProcAddress function to retrieve addresses of exported functions in DLLs.

The spelling of the function name (pointed to by lpszProc) must be identical to the spelling as it appears in the EXPORTS section of the source DLL's module-definition (.DEF) file.

When using an ordinal value to specify the function, it is possible for the function to return a non-NULL value even though the function with the specified ordinal does not exist. This can occur if the DLL's module definition file has specified ordinals using something other than the range [1..n] where n is the number of exported functions.