Utilizzare funzioni contenute in una DLL in C++

From RVM Wiki
Revision as of 17:06, 25 October 2009 by Gabriele.vivinetto (talk | contribs)
Jump to navigation Jump to search

Esempio:

#include <windows.h>
#include <stdio.h>	

int main () {
	
	/*Typedef the hello function*/
	typedef void (*pfunc)();
	
	/*Windows handle*/
	HANDLE hdll;
	
	/*A pointer to a function*/
	pfunc hello;
	
	/*LoadLibrary*/
	hdll = LoadLibrary("message.dll");
	
	/*GetProcAddress*/
	hello = (pfunc)GetProcAddress(hdll, "hello");
	
	/*Call the function*/
	hello();
	return 0;
}

Come esempio da richiamare, si può usare la funzione isUserAdmin contenuta nella DLL standard di Windows shell32.dll: MSDN:IsUserAnAdmin Function ()


Riferimenti