Hello there! I'm currently doing some VC++ programming. I'm using MFC programming and DLL which is explicitly linked. I have placed my initialization and the usage of GetProcAdress inside my "buttonClicked" function. When a button is clicked, the function in the DLL should be called.

void CSample::buttonClicked(){
		pSampleFunc = (SampleFunc)GetProcAddress(hLib, "Sample");
		if(pSampleFunc ){
			pSampleFunc (iVar, cVar);

		MessageBox("Library Failed!");



The first execution of the button is successful but if I pressed it the second time, it does nothing. What do you think is the problem? Please advise. Thank you. :)

Since you are calling FreeLibrary(hLib); , maybe you've forgotten to (re)LoadLibrary(...)?

I have solved the problem. I transferred FreeLibrary function in my exit function and transferred my initializationof pSampleFunc to OnInit function. :)