I am loading an extension dll from my mfc client application, when click on the menu first time the dll dialog is being loade and after i exit or close the dialog, and again clicking on the menu to load again it's giving error that "A required resource was unavailable". what could be the problem please help me to resolve this

void CTestRevApp ::On3DView()
{
    typedef VOID (*MYPROC)(CString);
    
	MYPROC ProcAdd;
    BOOL fRunTimeLinkSuccess = FALSE;

    
	hinstLib = LoadLibrary(L"C:\\Documents and Settings\\sdh\\My Documents\\REVOLUTIONPROJ_DB\\DllDialog\\package\\DllTest\\Release\\dlltest.dll");
	
	if( hinstLib == NULL)
	   FreeLibrary(hinstLib);
 

	ProcAdd = (MYPROC)GetProcAddress(hinstLib, "runAppli");
	ProcAdd(NULL);
	if(ProcAdd == NULL)
	{
		AfxMessageBox(L"Unable to get pointer to function runAppi()");
	    FreeLibrary(hinstLib);
	    hinstLib = NULL;
		return;
    }
    
	return;
}

Recommended Answers

All 3 Replies

Line 12 is pretty much useless. If LoadLibrary() fails then there is no reason to call FreeLibrary(). Call FreeLibrary() only when the process is done using it. Also, add an error message and return on line 13 when LoadLibrary() fails.

Why it fails to work the second time, I don't know.

can u write your mail id so that I can send you the project ? can u help me ?

I have got the problem I have implemented the PrecreateWindow for my view class.
just check this code.

BOOL CMyView::PreCreateWindow(CREATESTRUCT& cs)
{
	cs.lpszClass = ::AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_OWNDC,::LoadCursor(NULL, IDC_ARROW), NULL, NULL);

    cs.style |= WS_CLIPSIBLINGS | WS_CLIPCHILDREN;

    cs.dwExStyle = WS_EX_CLIENTEDGE; 

	return CView::PreCreateWindow(cs);
}

If I remove the first line, i.e
cs.lpszClass = ::AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_OWNDC,::LoadCursor(NULL, IDC_ARROW), NULL, NULL);
then my dll window is coming all the times from the client call. But it's flickering .
So now please help me what can I do to resolve this. I think some of you must have understood the problem, please help me. Thanks a lot.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.