GetProcAddress的参数和返回值,怎么正确使用(解释逻辑),哪位高手给个完整的加载库的例子

GetProcAddress的参数和返回值,如何正确使用(解释逻辑),谁给个完整的加载库的例子
RT

------解决方案--------------------
#include <windows.h> 
#include <stdio.h> 
 
typedef int (__cdecl *MYPROC)(LPWSTR); 
 
VOID main(VOID) 

HINSTANCE hinstLib; 
MYPROC ProcAdd; 
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE; 
 
// Get a handle to the DLL module.
 
hinstLib = LoadLibrary(TEXT("myputs")); 
 
// If the handle is valid, try to get the function address.
 
if (hinstLib != NULL) 

ProcAdd = (MYPROC) GetProcAddress(hinstLib, "myPuts"); 
 
// If the function address is valid, call the function.
 
if (NULL != ProcAdd) 
{
fRunTimeLinkSuccess = TRUE;
(ProcAdd) (L"Message sent to the DLL function\n"); 
}
 
// Free the DLL module.
 
fFreeResult = FreeLibrary(hinstLib); 

 
// If unable to call the DLL function, use an alternative.
 
if (! fRunTimeLinkSuccess) 
printf("Message printed from executable\n"); 
}
------解决方案--------------------
typedef int (__cdecl *MYPROC)(LPWSTR); 

 HINSTANCE hinstLib; 
 MYPROC ProcAdd; 
 hinstLib = LoadLibrary("myputs"); 

if (hinstLib != NULL) 

ProcAdd = (MYPROC) GetProcAddress(hinstLib, "myPuts"); 
 
if (NULL != ProcAdd) 
{
 (ProcAdd) ("hello\n"); 
}
fFreeResult = FreeLibrary(hinstLib); 

 

------解决方案--------------------
mark
------解决方案--------------------
int (__cdecl *MYPROC)(LPWSTR);

int 表示函数的返回值为 int
(__cdecl *MYPROC) 说明这是一个函数指针,调用方式为 __cdecl
LPWSTR 说明此函数有一个参数,类型为 LPWSTR
------解决方案--------------------
探讨
引用:
int (__cdecl *MYPROC)(LPWSTR);

int 表示函数的返回值为 int
(__cdecl *MYPROC) 说明这是一个函数指针,调用方式为 __cdecl
LPWSTR 说明此函数有一个参数,类型为 LPWSTR


为什么要用这么复杂的参数