Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
HMODULE handleToDLL;
/* you will need this handle in the "GetProcAddress" function call*/
/* here you load the desired DLL in the memory
You may use the full path of the DLL if its location is not included in the search path. Kernel32 is in the System(32) dir, so we can refer to it just like this*/
handleToDLL=LoadLibrary("Kernel32.DLL");
// if the DLL cannot be loaded exit the function
if(handleToDLL == NULL) return;
else MessageBox("Library loaded!");
/*When you want to call a function from a DLL, first you need its base address (a pointer). The "GetProcAddress" function will return this address, so you will got a pointer to the DLL function. Hereunder there is a typedef for such a function pointer. We know that the function we want to call ("CreateToolhelp32Snapshot") returns a HANDLE and it takes two DWORD parameters, so we define the LPCREATETOOLHELP32SNAPSHOT type like follows: */
typedef HANDLE (WINAPI *LPCREATETOOLHELP32SNAPSHOT)(DWORD,DWORD);
/*declare the function pointer you will use to call the function */
LPCREATETOOLHELP32SNAPSHOT lpfCreateToolhelp32Snapshot;
/*We need the base address of the function "CreateToolhelp32Snapshot" from the loaded DLL. Notice that the first parameter of the function is the handle to our loaded library, and the second one is the name of the function.*/
lpfCreateToolhelp32Snapshot=(LPCREATETOOLHELP32SNAPSHOT)GetProcAddress(handleToDLL,"CreateToolhelp32Snapshot");
if(!lpfCreateToolhelp32Snapshot)
{
// if the function cannot be found, discard the DLL
FreeLibrary(handleToDLL);
return;
}
else
MessageBox("Function address found!");
// And finally you can call the function !
HANDLE hProcessList = lpfCreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
//.....processing........
// When you don't need anymore the DLL, you discard it from the memory.
FreeLibrary(handleToDLL);