954,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Help me understand this code

1. typedef int (*MYPROC)(LPTSTR);
2. hinstLib = LoadLibrary(TEXT("myputs"));
3. ProcAdd = (MYPROC) GetProcAddress(hinstLib, TEXT("myPuts"));

Mahen
Junior Poster
144 posts since Aug 2004
Reputation Points: 10
Solved Threads: 2
 

>1. typedef int (*MYPROC)(LPTSTR);

This declares an alias MYPROC which is a pointer to a function taking an LPTSTR as a parameter and returning an int.

>2. hinstLib = LoadLibrary(TEXT("myputs"));

This is a call to the function LoadLibrary, which is passed the parameter of TEXT("myputs") -- TEXT is likely a macro that may be used to make it a string of wide characters if applicable. The return value of the function is assigned to hinstLib.

>3. ProcAdd = (MYPROC) GetProcAddress(hinstLib, TEXT("myPuts"));

This is a call to the function GetProcAddress, which is passed the parameters of hinstLib and TEXT("myPuts"). The return value of the function is cast to a pointer to a function taking an LPTSTR as a parameter and returning an int, and this result is assigned to ProcAdd.

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You