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.
  • L Lost User

    Once again, please put <pre> tags around your code so we can read it clearly, it is not easy to understand what your code is trying to do without it. As to your code, I still do not understand (and you have not explained) what you are trying to do with this dll; which, incidentally seems to change with every reply you post. Forget everything you have done in the past and try to explain clearly exactly what you are trying to achieve.

    Unrequited desire is character building. OriginalGriff

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

    Now my code looks like this. My application launching but crashing. [pre] void CClientRevProjDlg::OnBnClickedButton1() { typedef VOID (*MYPROC)(HWND); HINSTANCE hinstLib; MYPROC ProcAdd; BOOL fFreeResult, fRunTimeLinkSuccess = FALSE; HWND h = AfxGetMainWnd()->GetSafeHwnd(); // Get a handle to the DLL module. hinstLib = LoadLibrary(L"C:\\Users\\DasmahapatraS\\Projects\\Bhagavan_Cadem\\RevolutionProj\\debug\\RevolutionProj.dll"); // If the handle is valid, try to get the function address. if (hinstLib != NULL) { ProcAdd = (MYPROC) GetProcAddress(hinstLib, "runAppli"); // Do add operation // If the function address is valid, call the function. if (fRunTimeLinkSuccess = (ProcAdd != NULL)) (ProcAdd) (h); // Free the DLL module. fFreeResult = FreeLibrary(hinstLib); } // If unable to call the DLL function, use an alternative. if (! fRunTimeLinkSuccess) printf("message via alternative method\n"); } [/pre] ///////////////////////////////////////////////////////////////////////////////////// And runAppli like this... [code]

    extern "C" BOOL __declspec(dllexport) runAppli(HWND h)
    {
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
    // HWND h = AfxGetMainWnd()->GetSafeHwnd();
    ShowWindow(h,SW_SHOW);
    return true;
    }

    [/code]

    L 1 Reply Last reply
    0
    • A appollosputnik

      Now my code looks like this. My application launching but crashing. [pre] void CClientRevProjDlg::OnBnClickedButton1() { typedef VOID (*MYPROC)(HWND); HINSTANCE hinstLib; MYPROC ProcAdd; BOOL fFreeResult, fRunTimeLinkSuccess = FALSE; HWND h = AfxGetMainWnd()->GetSafeHwnd(); // Get a handle to the DLL module. hinstLib = LoadLibrary(L"C:\\Users\\DasmahapatraS\\Projects\\Bhagavan_Cadem\\RevolutionProj\\debug\\RevolutionProj.dll"); // If the handle is valid, try to get the function address. if (hinstLib != NULL) { ProcAdd = (MYPROC) GetProcAddress(hinstLib, "runAppli"); // Do add operation // If the function address is valid, call the function. if (fRunTimeLinkSuccess = (ProcAdd != NULL)) (ProcAdd) (h); // Free the DLL module. fFreeResult = FreeLibrary(hinstLib); } // If unable to call the DLL function, use an alternative. if (! fRunTimeLinkSuccess) printf("message via alternative method\n"); } [/pre] ///////////////////////////////////////////////////////////////////////////////////// And runAppli like this... [code]

      extern "C" BOOL __declspec(dllexport) runAppli(HWND h)
      {
      AFX_MANAGE_STATE(AfxGetStaticModuleState());
      // HWND h = AfxGetMainWnd()->GetSafeHwnd();
      ShowWindow(h,SW_SHOW);
      return true;
      }

      [/code]

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

      1. You still have not properly used <pre> tags around your code as requested. 2. You are really wasting your time with this; as I said before forget using this DLL as it serves no purpose. Create an application as an application and do things the right way.

      Unrequited desire is character building. OriginalGriff

      A 2 Replies Last reply
      0
      • L Lost User

        1. You still have not properly used <pre> tags around your code as requested. 2. You are really wasting your time with this; as I said before forget using this DLL as it serves no purpose. Create an application as an application and do things the right way.

        Unrequited desire is character building. OriginalGriff

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

        :) I need this dll to work Richard. Its very important......My application should be served as a dll. And my mainwindow should appear.

        L 1 Reply Last reply
        0
        • A appollosputnik

          :) I need this dll to work Richard. Its very important......My application should be served as a dll. And my mainwindow should appear.

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

          Why do you persist with this? This is totally contrary to the design of Windows applications. Putting all this code into a DLL is just going to cause you problems and, as I have said repeatedly, serves absolutely no purpose. Perhpas if you actually explained what problem you are trying to resolve someone can advise you of a potential solution, but just insisting that you need this as a DLL makes no sense.

          Unrequited desire is character building. OriginalGriff

          A 1 Reply Last reply
          0
          • L Lost User

            1. You still have not properly used <pre> tags around your code as requested. 2. You are really wasting your time with this; as I said before forget using this DLL as it serves no purpose. Create an application as an application and do things the right way.

            Unrequited desire is character building. OriginalGriff

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

            window handle is creaeing all the problem check this I am trying to get the handle like this [code] HWND h = this->m_hWnd; [/code] from the dialog class.....This is giving problem.....PLease tell me how can I get the window handle from dialog class. HWND handle. If I get the correct handle then it'll launch the application. Thanks Sujan

            L G 2 Replies Last reply
            0
            • L Lost User

              Why do you persist with this? This is totally contrary to the design of Windows applications. Putting all this code into a DLL is just going to cause you problems and, as I have said repeatedly, serves absolutely no purpose. Perhpas if you actually explained what problem you are trying to resolve someone can advise you of a potential solution, but just insisting that you need this as a DLL makes no sense.

              Unrequited desire is character building. OriginalGriff

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

              Problem I have explained earlier also. I have built one application in mfc...Now I want to launch that application from another aplication. so I want to make the first application as dll and try to laucnh that application from my 2nd application. Howelse would that be achieved except dll. ??? you tell me. Thanks Sujan

              L 1 Reply Last reply
              0
              • A appollosputnik

                window handle is creaeing all the problem check this I am trying to get the handle like this [code] HWND h = this->m_hWnd; [/code] from the dialog class.....This is giving problem.....PLease tell me how can I get the window handle from dialog class. HWND handle. If I get the correct handle then it'll launch the application. Thanks Sujan

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

                Sorry, but I don't understand what you are saying. The last few messages you were trying to launch an MFC application held inside a DLL, and now you seem to be doing something else that does not make sense. Where does this dialog fit in to what you have been talking about? And you still have not figured out how to add <pre> tags around your code!

                Unrequited desire is character building. OriginalGriff

                1 Reply Last reply
                0
                • A appollosputnik

                  Problem I have explained earlier also. I have built one application in mfc...Now I want to launch that application from another aplication. so I want to make the first application as dll and try to laucnh that application from my 2nd application. Howelse would that be achieved except dll. ??? you tell me. Thanks Sujan

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

                  sujandasmahapatra wrote:

                  Howelse would that be achieved except dll.

                  This has nothing to do with DLLs; I can only repeat: this is not the way to do it, DLLs are shared libraries not stand alone applications. If you want to launch a second application from a first then use one of the proper API functions[^].

                  Unrequited desire is character building. OriginalGriff

                  1 Reply Last reply
                  0
                  • A appollosputnik

                    window handle is creaeing all the problem check this I am trying to get the handle like this [code] HWND h = this->m_hWnd; [/code] from the dialog class.....This is giving problem.....PLease tell me how can I get the window handle from dialog class. HWND handle. If I get the correct handle then it'll launch the application. Thanks Sujan

                    G Offline
                    G Offline
                    Goto_Label_
                    wrote on last edited by
                    #38

                    HWND is a public member of CDialog -- you can access it just like any other member of CDialog class.

                    HWND CMyDialog::GetHandle()
                    {
                    return m_hWnd;
                    }

                    L A 2 Replies Last reply
                    0
                    • G Goto_Label_

                      HWND is a public member of CDialog -- you can access it just like any other member of CDialog class.

                      HWND CMyDialog::GetHandle()
                      {
                      return m_hWnd;
                      }

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

                      Yet_another_Coder_Dude wrote:

                      HWND is a public member of CDialog

                      No, HWND is a type defined in Windows.h.

                      Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

                      1 Reply Last reply
                      0
                      • G Goto_Label_

                        HWND is a public member of CDialog -- you can access it just like any other member of CDialog class.

                        HWND CMyDialog::GetHandle()
                        {
                        return m_hWnd;
                        }

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

                        when I try to access the m_hWnd from my dialog it says "unused ???"....Why is it so . [code] MyView::OnButtonClick() { HWND h = m_hWnd; //h is coming as unsed ??? its not getting good value. } [/code] Please tell me whats going wrong in this ? Thanks Sujan

                        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