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(){
	if(hLib){
		pSampleFunc = (SampleFunc)GetProcAddress(hLib, "Sample");
		
		if(pSampleFunc ){
			
			pSampleFunc (iVar, cVar);
		}

		FreeLibrary(hLib);
	}else{
		MessageBox("Library Failed!");
	}

        //DO SOME STUFF HERE
       ......

}

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. :)

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

This question has already been answered. Start a new discussion instead.