Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. dll from win32 console.

dll from win32 console.

Scheduled Pinned Locked Moved C / C++ / MFC
c++debugginghelp
40 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    appollosputnik
    wrote on last edited by
    #1

    Dear Friends I have a mfc application which I already converted to a dll. now I want to launch that application from another win32 client application. So how I can achieve this. Any h elp would be highly appreciated. check my code snippet. //in App.h header extern "C" __declspec(dllexport) void runAppli(); //in App.cpp __declspec(dllexport) void runAppli(HWND hWnd) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); } //In the client console int main(int argc, char **argv) { typedef void (*EntryPointfuncPtr)(int argc, const char * argv ); HINSTANCE LoadMe; LoadMe = LoadLibrary(L"C:\\Users\\DasmahapatraS\\Projects\\Bhagavan_Cadem\\RevolutionProj\\debug\\RevolutionProj.dll"); if (LoadMe != 0) printf("LoadMe library loaded!\n"); else printf("LoadMe library failed to load!\n"); EntryPointfuncPtr LibMainEntryPoint; LibMainEntryPoint = (EntryPointfuncPtr)GetProcAddress(LoadMe,"runAppli"); return 0; } I am not able to launch with this code. Please tell me whats going wrong... My application is appearing and disappearing from the screen. Thanks a lot for any help. Sujan

    C L 2 Replies Last reply
    0
    • A appollosputnik

      Dear Friends I have a mfc application which I already converted to a dll. now I want to launch that application from another win32 client application. So how I can achieve this. Any h elp would be highly appreciated. check my code snippet. //in App.h header extern "C" __declspec(dllexport) void runAppli(); //in App.cpp __declspec(dllexport) void runAppli(HWND hWnd) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); } //In the client console int main(int argc, char **argv) { typedef void (*EntryPointfuncPtr)(int argc, const char * argv ); HINSTANCE LoadMe; LoadMe = LoadLibrary(L"C:\\Users\\DasmahapatraS\\Projects\\Bhagavan_Cadem\\RevolutionProj\\debug\\RevolutionProj.dll"); if (LoadMe != 0) printf("LoadMe library loaded!\n"); else printf("LoadMe library failed to load!\n"); EntryPointfuncPtr LibMainEntryPoint; LibMainEntryPoint = (EntryPointfuncPtr)GetProcAddress(LoadMe,"runAppli"); return 0; } I am not able to launch with this code. Please tell me whats going wrong... My application is appearing and disappearing from the screen. Thanks a lot for any help. Sujan

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      sujandasmahapatra wrote:

      My application is appearing and disappearing from the screen.

      when? have you tried stepping through it in the debugger?

      image processing toolkits | batch image processing

      A 1 Reply Last reply
      0
      • C Chris Losinger

        sujandasmahapatra wrote:

        My application is appearing and disappearing from the screen.

        when? have you tried stepping through it in the debugger?

        image processing toolkits | batch image processing

        A Offline
        A Offline
        appollosputnik
        wrote on last edited by
        #3

        nothing is happening with debugger..its dll..... appearing and disappearing....please give me some suggestion how can i launch the dll application from console client. Thanks a lot for comments. Thanks Sujan

        C 1 Reply Last reply
        0
        • A appollosputnik

          nothing is happening with debugger..its dll..... appearing and disappearing....please give me some suggestion how can i launch the dll application from console client. Thanks a lot for comments. Thanks Sujan

          C Offline
          C Offline
          Chris Losinger
          wrote on last edited by
          #4

          sujandasmahapatra wrote:

          nothing is happening with debugger..its dll.....

          have you tried stepping into the DLL code to see what it's doing? http://support.microsoft.com/kb/85221[^]

          image processing toolkits | batch image processing

          1 Reply Last reply
          0
          • A appollosputnik

            Dear Friends I have a mfc application which I already converted to a dll. now I want to launch that application from another win32 client application. So how I can achieve this. Any h elp would be highly appreciated. check my code snippet. //in App.h header extern "C" __declspec(dllexport) void runAppli(); //in App.cpp __declspec(dllexport) void runAppli(HWND hWnd) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); } //In the client console int main(int argc, char **argv) { typedef void (*EntryPointfuncPtr)(int argc, const char * argv ); HINSTANCE LoadMe; LoadMe = LoadLibrary(L"C:\\Users\\DasmahapatraS\\Projects\\Bhagavan_Cadem\\RevolutionProj\\debug\\RevolutionProj.dll"); if (LoadMe != 0) printf("LoadMe library loaded!\n"); else printf("LoadMe library failed to load!\n"); EntryPointfuncPtr LibMainEntryPoint; LibMainEntryPoint = (EntryPointfuncPtr)GetProcAddress(LoadMe,"runAppli"); return 0; } I am not able to launch with this code. Please tell me whats going wrong... My application is appearing and disappearing from the screen. Thanks a lot for any help. Sujan

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            That's hardly surprising since it's a console app trying to run a Windows DLL. you also seem to have a discrepancy between the definition of your runAppli() function and its implementation.

            Unrequited desire is character building. OriginalGriff

            A 1 Reply Last reply
            0
            • L Lost User

              That's hardly surprising since it's a console app trying to run a Windows DLL. you also seem to have a discrepancy between the definition of your runAppli() function and its implementation.

              Unrequited desire is character building. OriginalGriff

              A Offline
              A Offline
              appollosputnik
              wrote on last edited by
              #6

              I am able to reduce the code to this much but still its crashing... ///////////////////////////////////////////////////////////////////////////////////// int main(int argc, char **argv) { /* get handle to dll */ HINSTANCE hGetProcIDDLL = LoadLibrary(TEXT("C:\\Users\\DasmahapatraS\\Projects\\Bhagavan_Cadem\\RevolutionProj\\debug\\RevolutionProj.dll")); /* get pointer to the function in the dll*/ FARPROC lpfnGetProcessID = GetProcAddress(HMODULE (hGetProcIDDLL),"runAppli"); /* Define the Function in the DLL for reuse. This is just prototyping the dll's function. A mock of it. Use "stdcall" for maximum compatibility. */ typedef BOOL (* pICFUNC)(HINSTANCE, LPCSTR); pICFUNC MyFunction=NULL; ///* The actual call to the function contained in the dll */ BOOL intMyReturnVal = MyFunction(HMODULE (hGetProcIDDLL), "runAppli"); /* Release the Dll */ FreeLibrary(hGetProcIDDLL); return 0; } ///////////////////////////////////////////////////////////////////////////////////// __declspec(dllexport) void runAppli() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); } ////////////////////////////////////////////////////////////////////////////////////

              L 1 Reply Last reply
              0
              • A appollosputnik

                I am able to reduce the code to this much but still its crashing... ///////////////////////////////////////////////////////////////////////////////////// int main(int argc, char **argv) { /* get handle to dll */ HINSTANCE hGetProcIDDLL = LoadLibrary(TEXT("C:\\Users\\DasmahapatraS\\Projects\\Bhagavan_Cadem\\RevolutionProj\\debug\\RevolutionProj.dll")); /* get pointer to the function in the dll*/ FARPROC lpfnGetProcessID = GetProcAddress(HMODULE (hGetProcIDDLL),"runAppli"); /* Define the Function in the DLL for reuse. This is just prototyping the dll's function. A mock of it. Use "stdcall" for maximum compatibility. */ typedef BOOL (* pICFUNC)(HINSTANCE, LPCSTR); pICFUNC MyFunction=NULL; ///* The actual call to the function contained in the dll */ BOOL intMyReturnVal = MyFunction(HMODULE (hGetProcIDDLL), "runAppli"); /* Release the Dll */ FreeLibrary(hGetProcIDDLL); return 0; } ///////////////////////////////////////////////////////////////////////////////////// __declspec(dllexport) void runAppli() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); } ////////////////////////////////////////////////////////////////////////////////////

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                First point: please use <pre> tags around your code so that it is more readable. Second point:

                pICFUNC MyFunction=NULL;
                ///* The actual call to the function contained in the dll */
                BOOL intMyReturnVal = MyFunction(HMODULE (hGetProcIDDLL), "runAppli");

                how do you expect a call to a NULL address not to crash?

                Unrequited desire is character building. OriginalGriff

                A 1 Reply Last reply
                0
                • L Lost User

                  First point: please use <pre> tags around your code so that it is more readable. Second point:

                  pICFUNC MyFunction=NULL;
                  ///* The actual call to the function contained in the dll */
                  BOOL intMyReturnVal = MyFunction(HMODULE (hGetProcIDDLL), "runAppli");

                  how do you expect a call to a NULL address not to crash?

                  Unrequited desire is character building. OriginalGriff

                  A Offline
                  A Offline
                  appollosputnik
                  wrote on last edited by
                  #8

                  Now I am writing like this. int main(int argc, char **argv) { /* get handle to dll */ HINSTANCE hGetProcIDDLL = LoadLibrary(TEXT("C:\\Users\\DasmahapatraS\\Projects\\Bhagavan_Cadem\\RevolutionProj\\debug\\RevolutionProj.dll")); typedef BOOL (* pICFUNC)(HINSTANCE, LPCSTR); pICFUNC lpfnGetProcessID = (pICFUNC)GetProcAddress((HMODULE) hGetProcIDDLL,"runAppli"); ///* The actual call to the function contained in the dll */ BOOL intMyReturnVal = lpfnGetProcessID((HMODULE) hGetProcIDDLL, "runAppli"); /* Release the Dll */ FreeLibrary(hGetProcIDDLL); return 0; } ////////////////////////////////////////////////////////////////////////////////////////////////////// BOOL __declspec(dllexport) runAppli(HWND hwnd, LPCSTR lpAppName) { // Only needed if resources are accessed //AFX_MANAGE_STATE(AfxGetStaticModuleState()); ::ShowWindow(hwnd, SW_SHOW); UNREFERENCED_PARAMETER(lpAppName); return true; } Somebody suggested this piece of code. But nothing is appearing with this. My mainwindow of the dll application is not coming. Can u tell me whats wrong still in this. Thanks a lot for your help. Sujan

                  S 1 Reply Last reply
                  0
                  • A appollosputnik

                    Now I am writing like this. int main(int argc, char **argv) { /* get handle to dll */ HINSTANCE hGetProcIDDLL = LoadLibrary(TEXT("C:\\Users\\DasmahapatraS\\Projects\\Bhagavan_Cadem\\RevolutionProj\\debug\\RevolutionProj.dll")); typedef BOOL (* pICFUNC)(HINSTANCE, LPCSTR); pICFUNC lpfnGetProcessID = (pICFUNC)GetProcAddress((HMODULE) hGetProcIDDLL,"runAppli"); ///* The actual call to the function contained in the dll */ BOOL intMyReturnVal = lpfnGetProcessID((HMODULE) hGetProcIDDLL, "runAppli"); /* Release the Dll */ FreeLibrary(hGetProcIDDLL); return 0; } ////////////////////////////////////////////////////////////////////////////////////////////////////// BOOL __declspec(dllexport) runAppli(HWND hwnd, LPCSTR lpAppName) { // Only needed if resources are accessed //AFX_MANAGE_STATE(AfxGetStaticModuleState()); ::ShowWindow(hwnd, SW_SHOW); UNREFERENCED_PARAMETER(lpAppName); return true; } Somebody suggested this piece of code. But nothing is appearing with this. My mainwindow of the dll application is not coming. Can u tell me whats wrong still in this. Thanks a lot for your help. Sujan

                    S Offline
                    S Offline
                    Stephen Hewitt
                    wrote on last edited by
                    #9

                    LoadLibrary[^] returns a HMODULE, not HINSTANCE. Alter the DLL loading to look like this:

                    HMODULE hDll = LoadLibrary(_T("C:\\Users\\DasmahapatraS\\Projects\\Bhagavan_Cadem\\RevolutionProj\\debug\\RevolutionProj.dll"));

                    Secondly, lose the cast like this (since you're now using the correct type above):

                    typedef BOOL (*PFUNC)(HINSTANCE, LPCSTR);
                    PFUNC pProc = (PFUNC)GetProcAddress(hDll, "runAppli");

                    Note also that I've added a _T (same as TEXT) which you left out. Now a guess at the cause of your problems: GetProcAddress[^] is failing because you're using the wrong function name by ignoring name mangling[^]. Change the DLL like this:

                    extern "C" BOOL __declspec(dllexport) runAppli(HWND hwnd, LPCSTR lpAppName)

                    Steve

                    A 2 Replies Last reply
                    0
                    • S Stephen Hewitt

                      LoadLibrary[^] returns a HMODULE, not HINSTANCE. Alter the DLL loading to look like this:

                      HMODULE hDll = LoadLibrary(_T("C:\\Users\\DasmahapatraS\\Projects\\Bhagavan_Cadem\\RevolutionProj\\debug\\RevolutionProj.dll"));

                      Secondly, lose the cast like this (since you're now using the correct type above):

                      typedef BOOL (*PFUNC)(HINSTANCE, LPCSTR);
                      PFUNC pProc = (PFUNC)GetProcAddress(hDll, "runAppli");

                      Note also that I've added a _T (same as TEXT) which you left out. Now a guess at the cause of your problems: GetProcAddress[^] is failing because you're using the wrong function name by ignoring name mangling[^]. Change the DLL like this:

                      extern "C" BOOL __declspec(dllexport) runAppli(HWND hwnd, LPCSTR lpAppName)

                      Steve

                      A Offline
                      A Offline
                      appollosputnik
                      wrote on last edited by
                      #10

                      With this even its not happening stephen... _T is not compiling so I have put only the text. its compiling Now the code looks like this.. int main(int argc, char **argv) { /* get handle to dll */ HMODULE hDll = LoadLibrary(TEXT("C:\\Users\\DasmahapatraS\\Projects\\Bhagavan_Cadem\\RevolutionProj\\debug\\RevolutionProj.dll")); typedef BOOL (* ICFUNC)(HINSTANCE, LPCSTR); ICFUNC lpfnGetProcessID = (ICFUNC)GetProcAddress(hDll, "runAppli"); ///* The actual call to the function contained in the dll */ BOOL intMyReturnVal = lpfnGetProcessID(hDll, "runAppli"); /* Release the Dll */ FreeLibrary(hDll); return 0; } extern "C" BOOL __declspec(dllexport) runAppli(HWND hwnd, LPCSTR lpAppName) { // Only needed if resources are accessed //AFX_MANAGE_STATE(AfxGetStaticModuleState()); ::ShowWindow(hwnd, SW_SHOW); UNREFERENCED_PARAMETER(lpAppName); return true; }

                      S 1 Reply Last reply
                      0
                      • S Stephen Hewitt

                        LoadLibrary[^] returns a HMODULE, not HINSTANCE. Alter the DLL loading to look like this:

                        HMODULE hDll = LoadLibrary(_T("C:\\Users\\DasmahapatraS\\Projects\\Bhagavan_Cadem\\RevolutionProj\\debug\\RevolutionProj.dll"));

                        Secondly, lose the cast like this (since you're now using the correct type above):

                        typedef BOOL (*PFUNC)(HINSTANCE, LPCSTR);
                        PFUNC pProc = (PFUNC)GetProcAddress(hDll, "runAppli");

                        Note also that I've added a _T (same as TEXT) which you left out. Now a guess at the cause of your problems: GetProcAddress[^] is failing because you're using the wrong function name by ignoring name mangling[^]. Change the DLL like this:

                        extern "C" BOOL __declspec(dllexport) runAppli(HWND hwnd, LPCSTR lpAppName)

                        Steve

                        A Offline
                        A Offline
                        appollosputnik
                        wrote on last edited by
                        #11

                        Now the code is looking like this ....But still application is not launching. int main(int argc, char **argv) { /* get handle to dll */ HMODULE hDll = LoadLibrary(TEXT("C:\\Users\\DasmahapatraS\\Projects\\Bhagavan_Cadem\\RevolutionProj\\debug\\RevolutionProj.dll")); typedef BOOL (* ICFUNC)(HINSTANCE, LPCSTR); ICFUNC lpfnGetProcessID = (ICFUNC)GetProcAddress(hDll, "runAppli"); ///* The actual call to the function contained in the dll */ BOOL intMyReturnVal = lpfnGetProcessID(hDll, "runAppli"); /* Release the Dll */ FreeLibrary(hDll); return 0; } /////////////////////////////////////////////////////////////////////////////////////////////////////////// extern "C" BOOL __declspec(dllexport) runAppli(HWND hwnd, LPCSTR lpAppName) { // Only needed if resources are accessed //AFX_MANAGE_STATE(AfxGetStaticModuleState()); ::ShowWindow(hwnd, SW_SHOW); UNREFERENCED_PARAMETER(lpAppName); return true; }

                        S 1 Reply Last reply
                        0
                        • A appollosputnik

                          With this even its not happening stephen... _T is not compiling so I have put only the text. its compiling Now the code looks like this.. int main(int argc, char **argv) { /* get handle to dll */ HMODULE hDll = LoadLibrary(TEXT("C:\\Users\\DasmahapatraS\\Projects\\Bhagavan_Cadem\\RevolutionProj\\debug\\RevolutionProj.dll")); typedef BOOL (* ICFUNC)(HINSTANCE, LPCSTR); ICFUNC lpfnGetProcessID = (ICFUNC)GetProcAddress(hDll, "runAppli"); ///* The actual call to the function contained in the dll */ BOOL intMyReturnVal = lpfnGetProcessID(hDll, "runAppli"); /* Release the Dll */ FreeLibrary(hDll); return 0; } extern "C" BOOL __declspec(dllexport) runAppli(HWND hwnd, LPCSTR lpAppName) { // Only needed if resources are accessed //AFX_MANAGE_STATE(AfxGetStaticModuleState()); ::ShowWindow(hwnd, SW_SHOW); UNREFERENCED_PARAMETER(lpAppName); return true; }

                          S Offline
                          S Offline
                          Stephen Hewitt
                          wrote on last edited by
                          #12

                          sujandasmahapatra wrote:

                          With this even its not happening stephen...
                          _T is not compiling so I have put only the text. its compiling

                          Yeah, I was wrong on that point. You don't use _T on GetProcAddress. I have modified my post to reflect this.   So it works now?

                          Steve

                          1 Reply Last reply
                          0
                          • A appollosputnik

                            Now the code is looking like this ....But still application is not launching. int main(int argc, char **argv) { /* get handle to dll */ HMODULE hDll = LoadLibrary(TEXT("C:\\Users\\DasmahapatraS\\Projects\\Bhagavan_Cadem\\RevolutionProj\\debug\\RevolutionProj.dll")); typedef BOOL (* ICFUNC)(HINSTANCE, LPCSTR); ICFUNC lpfnGetProcessID = (ICFUNC)GetProcAddress(hDll, "runAppli"); ///* The actual call to the function contained in the dll */ BOOL intMyReturnVal = lpfnGetProcessID(hDll, "runAppli"); /* Release the Dll */ FreeLibrary(hDll); return 0; } /////////////////////////////////////////////////////////////////////////////////////////////////////////// extern "C" BOOL __declspec(dllexport) runAppli(HWND hwnd, LPCSTR lpAppName) { // Only needed if resources are accessed //AFX_MANAGE_STATE(AfxGetStaticModuleState()); ::ShowWindow(hwnd, SW_SHOW); UNREFERENCED_PARAMETER(lpAppName); return true; }

                            S Offline
                            S Offline
                            Stephen Hewitt
                            wrote on last edited by
                            #13

                            Why are you passing a HMODULE when a HWND is expected?

                            sujandasmahapatra wrote:

                            BOOL intMyReturnVal = lpfnGetProcessID(hDll, "runAppli");

                            sujandasmahapatra wrote:

                            extern "C" BOOL __declspec(dllexport) runAppli(HWND hwnd, LPCSTR lpAppName)

                            Steve

                            A 4 Replies Last reply
                            0
                            • S Stephen Hewitt

                              Why are you passing a HMODULE when a HWND is expected?

                              sujandasmahapatra wrote:

                              BOOL intMyReturnVal = lpfnGetProcessID(hDll, "runAppli");

                              sujandasmahapatra wrote:

                              extern "C" BOOL __declspec(dllexport) runAppli(HWND hwnd, LPCSTR lpAppName)

                              Steve

                              A Offline
                              A Offline
                              appollosputnik
                              wrote on last edited by
                              #14

                              With this even its not launching the application. simply returning. dll application is not launching. some more things are missing it seems. Please let me know if you're able to figure it out. Thanks for your help sujan

                              1 Reply Last reply
                              0
                              • S Stephen Hewitt

                                Why are you passing a HMODULE when a HWND is expected?

                                sujandasmahapatra wrote:

                                BOOL intMyReturnVal = lpfnGetProcessID(hDll, "runAppli");

                                sujandasmahapatra wrote:

                                extern "C" BOOL __declspec(dllexport) runAppli(HWND hwnd, LPCSTR lpAppName)

                                Steve

                                A Offline
                                A Offline
                                appollosputnik
                                wrote on last edited by
                                #15

                                typedef BOOL (* ICFUNC)(HINSTANCE, LPCSTR); ICFUNC lpfnGetProcessID = (ICFUNC)GetProcAddress(hDll, "runAppli"); ///* The actual call to the function contained in the dll */ BOOL intMyReturnVal = lpfnGetProcessID(hDll, "runAppli"); lpfnGetProcessID expects a HMODULE right...? Is it wrong. ??

                                1 Reply Last reply
                                0
                                • S Stephen Hewitt

                                  Why are you passing a HMODULE when a HWND is expected?

                                  sujandasmahapatra wrote:

                                  BOOL intMyReturnVal = lpfnGetProcessID(hDll, "runAppli");

                                  sujandasmahapatra wrote:

                                  extern "C" BOOL __declspec(dllexport) runAppli(HWND hwnd, LPCSTR lpAppName)

                                  Steve

                                  A Offline
                                  A Offline
                                  appollosputnik
                                  wrote on last edited by
                                  #16

                                  How can I get the handle from the client console and pass it to the lpfnGetProcessID .... to runAppli....With the code below I am getting run-time error. that hwnd being used without being intialized.. Please tell me how can I initialize hwnd. Thanks Sujan int main(int argc, char **argv) { HWND hwnd; /* get handle to dll */ HMODULE hDll = LoadLibrary(TEXT("C:\\Users\\DasmahapatraS\\Projects\\Bhagavan_Cadem\\RevolutionProj\\debug\\RevolutionProj.dll")); typedef BOOL (* ICFUNC)(HWND, LPCSTR); ICFUNC lpfnGetProcessID = (ICFUNC)GetProcAddress(hDll, "runAppli"); ///* The actual call to the function contained in the dll */ BOOL intMyReturnVal = lpfnGetProcessID(hwnd, "runAppli"); /* Release the Dll */ FreeLibrary(hDll); return 0; }

                                  S 1 Reply Last reply
                                  0
                                  • A appollosputnik

                                    How can I get the handle from the client console and pass it to the lpfnGetProcessID .... to runAppli....With the code below I am getting run-time error. that hwnd being used without being intialized.. Please tell me how can I initialize hwnd. Thanks Sujan int main(int argc, char **argv) { HWND hwnd; /* get handle to dll */ HMODULE hDll = LoadLibrary(TEXT("C:\\Users\\DasmahapatraS\\Projects\\Bhagavan_Cadem\\RevolutionProj\\debug\\RevolutionProj.dll")); typedef BOOL (* ICFUNC)(HWND, LPCSTR); ICFUNC lpfnGetProcessID = (ICFUNC)GetProcAddress(hDll, "runAppli"); ///* The actual call to the function contained in the dll */ BOOL intMyReturnVal = lpfnGetProcessID(hwnd, "runAppli"); /* Release the Dll */ FreeLibrary(hDll); return 0; }

                                    S Offline
                                    S Offline
                                    Stephen Hewitt
                                    wrote on last edited by
                                    #17

                                    You're not explaining yourself very clearly but it sounds like you might be after the GetConsoleWindow function.

                                    Steve

                                    A 2 Replies Last reply
                                    0
                                    • S Stephen Hewitt

                                      You're not explaining yourself very clearly but it sounds like you might be after the GetConsoleWindow function.

                                      Steve

                                      A Offline
                                      A Offline
                                      appollosputnik
                                      wrote on last edited by
                                      #18

                                      extern "C" BOOL __declspec(dllexport) runAppli(HWND hwnd, LPCSTR lpAppName) { // Only needed if resources are accessed //AFX_MANAGE_STATE(AfxGetStaticModuleState()); ::ShowWindow(hwnd, SW_SHOW); UNREFERENCED_PARAMETER(lpAppName); return true; } So I need to pass hwnd to this function right..? Is it necessary to launch my dll application. I just want to launch the application.

                                      S 1 Reply Last reply
                                      0
                                      • A appollosputnik

                                        extern "C" BOOL __declspec(dllexport) runAppli(HWND hwnd, LPCSTR lpAppName) { // Only needed if resources are accessed //AFX_MANAGE_STATE(AfxGetStaticModuleState()); ::ShowWindow(hwnd, SW_SHOW); UNREFERENCED_PARAMETER(lpAppName); return true; } So I need to pass hwnd to this function right..? Is it necessary to launch my dll application. I just want to launch the application.

                                        S Offline
                                        S Offline
                                        Stephen Hewitt
                                        wrote on last edited by
                                        #19

                                        Why don't you explain exactly what you are trying to do?

                                        Steve

                                        A 2 Replies Last reply
                                        0
                                        • S Stephen Hewitt

                                          You're not explaining yourself very clearly but it sounds like you might be after the GetConsoleWindow function.

                                          Steve

                                          A Offline
                                          A Offline
                                          appollosputnik
                                          wrote on last edited by
                                          #20

                                          I have made some changes in the code let me know whats wrong in this my application is not launching. int main(int argc, char **argv) { HWND hWnd=NULL; /* get handle to dll */ HMODULE hDll = LoadLibrary(TEXT("C:\\Users\\DasmahapatraS\\Projects\\Bhagavan_Cadem\\RevolutionProj\\debug\\RevolutionProj.dll")); typedef BOOL (* ICFUNC)(LPCSTR); ICFUNC lpfnGetProcessID = (ICFUNC)GetProcAddress(hDll, "runAppli"); ///* The actual call to the function contained in the dll */ BOOL intMyReturnVal = lpfnGetProcessID("runAppli"); /* Release the Dll */ FreeLibrary(hDll); return 0; } //////////////////////////////////////////////////////////////////////////////////////////////////// extern "C" BOOL __declspec(dllexport) runAppli(LPCSTR lpAppName) { // Only needed if resources are accessed //AFX_MANAGE_STATE(AfxGetStaticModuleState()); ::ShowWindow( AfxGetMainWnd()->GetSafeHwnd(), SW_SHOW); UNREFERENCED_PARAMETER(lpAppName); return true; }

                                          L 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups