Solved

How Can I use MFC static linked DLL with Win32 Application

Posted on 1999-01-19
1
202 Views
Last Modified: 2013-11-20
I maked a win32 program like bellow

STEP 1. I have built MFC DLL in regular dll with  MFC static linked.
STEP 2. I customized Event Loop
        void checkMFCPanding()
        {
             MSG msg;

             if(GetMessage(&msg, (HWND)NULL, 0, 0)){
                  TranslateMessage(&msg);
    DispatchMessage(&msg);
              }
        }

        void EVENT_MainCustomLoop()
        {
S_Running = BOOL_TRUE;
  NDEvent::Update();
  while (S_Running) {
NDEvent::ProcessPending(); /// win32 Event Process
NDEvent::UpdateCursor();
checkMFCPanding();            /// MFC Event Process
Sleep(50);
   }
   NDEvent::Update();
          }


int main(int argc, char** argv)
{
                |
EVENT_MainCustomLoop(); /// Custom Event Loop
exit(0)
}

STEP3.: I use MFC DLL in explicit aproch.
    HINSTANCE hDll;
    void Oi_testWin1::HitPBut_Exit(void)
    {
FreeLibrary(hDll);
S_Running = BOOL_FALSE;
     }

    void Oi_testWin1::HitPBut_Call(void)
    {
typedef void (*MYPROC)();

MYPROC ProcChildShow;
BOOL fRunTimeLinkSuccess=FALSE;

hDll=LoadLibrary("dll4.dll");

ProcChildShow = (MYPROC) GetProcAddress(hDll, "Show_MyDlg");
if(fRunTimeLinkSuccess =(ProcChildShow != NULL)){
(ProcChildShow)();
}
    }

this can display MFC Dialog in DLL, but another ploblum comes.
The application killed when I call FreeLibrary(hDll) routine.

I really don't know what I made a mistake.
I think maybe step of build DLL (build MFC DLL in regular dll with  MFC static linked.).

Anybody know this, please Let me know as soon as possiblly.
please~~~
0
Comment
Question by:jbpark
1 Comment
 
LVL 31

Accepted Solution

by:
Zoppo earned 100 total points
ID: 1327995
I think your problem is your kind of 'syncronisation' with the S_Running:
In Oi_testWin1::HitPBut_Exit you try to unload the lib although the EVENT_MainCustomLoop() is still running.
Even if you set S_Running to FALSE befor freeing the DLL it's not said that EVENT_MainCustomLoop() terminates correctly in time.

You should use some of the Win32 API's syncronisation (see help).

Post if you have additional questions to syncronisation methods.

ZOPPO

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 49
Get filename and folder into excel 7 79
Pressing cancel button with C# UI Automation 3 81
mapAB Challlenge 35 157
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question