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. Find the exe name when loading dll

Find the exe name when loading dll

Scheduled Pinned Locked Moved C / C++ / MFC
helpdebuggingquestion
7 Posts 6 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 Offline
    L Offline
    lynchspawn
    wrote on last edited by
    #1

    I'm trying to debug a problem where multiple applications (exe's) are loading a common dll. I have some debug output in the InitInstance() and ExitInstance() of the dll's CWinApp class. I'd really like to know which app is loading/unloading for each line of debug output (I'm writing lines to a file) but have not found a way to do this. The m_pszExeName and m_pszAppName variables are always the name of the dll - so that's no help. The m_lpCmdLine is always blank so that's no help either. Is there a way to do this?

    S D L C D 5 Replies Last reply
    0
    • L lynchspawn

      I'm trying to debug a problem where multiple applications (exe's) are loading a common dll. I have some debug output in the InitInstance() and ExitInstance() of the dll's CWinApp class. I'd really like to know which app is loading/unloading for each line of debug output (I'm writing lines to a file) but have not found a way to do this. The m_pszExeName and m_pszAppName variables are always the name of the dll - so that's no help. The m_lpCmdLine is always blank so that's no help either. Is there a way to do this?

      S Offline
      S Offline
      SunKnight0
      wrote on last edited by
      #2

      I don't know if that is feasible, it depends on the complexity of your project, but you could add the executable's name as an extra variable to some key calls to the dll and have the executables just provide their name to the dll for logging/debugging purposes.

      1 Reply Last reply
      0
      • L lynchspawn

        I'm trying to debug a problem where multiple applications (exe's) are loading a common dll. I have some debug output in the InitInstance() and ExitInstance() of the dll's CWinApp class. I'd really like to know which app is loading/unloading for each line of debug output (I'm writing lines to a file) but have not found a way to do this. The m_pszExeName and m_pszAppName variables are always the name of the dll - so that's no help. The m_lpCmdLine is always blank so that's no help either. Is there a way to do this?

        D Offline
        D Offline
        Don Miguel
        wrote on last edited by
        #3

        This is not possible to found from the dll itself. Dll's are loaded (mapped in process address space) by the loader, so there could be a place to found which process load the dll. But I can't provide more help for you, my knowledge is limited to what I said.

        1 Reply Last reply
        0
        • L lynchspawn

          I'm trying to debug a problem where multiple applications (exe's) are loading a common dll. I have some debug output in the InitInstance() and ExitInstance() of the dll's CWinApp class. I'd really like to know which app is loading/unloading for each line of debug output (I'm writing lines to a file) but have not found a way to do this. The m_pszExeName and m_pszAppName variables are always the name of the dll - so that's no help. The m_lpCmdLine is always blank so that's no help either. Is there a way to do this?

          L Offline
          L Offline
          lynchspawn
          wrote on last edited by
          #4

          Bummer. Unfortunately, not all of the app's that call my dll are written by my company. I guess I can add something to detect my app but the rest will have to remain unidentified. Thanks anyway.

          T 1 Reply Last reply
          0
          • L lynchspawn

            I'm trying to debug a problem where multiple applications (exe's) are loading a common dll. I have some debug output in the InitInstance() and ExitInstance() of the dll's CWinApp class. I'd really like to know which app is loading/unloading for each line of debug output (I'm writing lines to a file) but have not found a way to do this. The m_pszExeName and m_pszAppName variables are always the name of the dll - so that's no help. The m_lpCmdLine is always blank so that's no help either. Is there a way to do this?

            C Offline
            C Offline
            cmk
            wrote on last edited by
            #5

            ::GetModuleFileName(GetModuleHandle(NULL), ...); ...cmk Save the whales - collect the whole set

            1 Reply Last reply
            0
            • L lynchspawn

              Bummer. Unfortunately, not all of the app's that call my dll are written by my company. I guess I can add something to detect my app but the rest will have to remain unidentified. Thanks anyway.

              T Offline
              T Offline
              ThatsAlok
              wrote on last edited by
              #6

              lynchspawn wrote: I can add something to detect my app but the rest will have to remain unidentified. Call the GetModuleFileName in your Code!

              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

              cheers, Alok Gupta VC Forum Q&A :- I/ IV

              1 Reply Last reply
              0
              • L lynchspawn

                I'm trying to debug a problem where multiple applications (exe's) are loading a common dll. I have some debug output in the InitInstance() and ExitInstance() of the dll's CWinApp class. I'd really like to know which app is loading/unloading for each line of debug output (I'm writing lines to a file) but have not found a way to do this. The m_pszExeName and m_pszAppName variables are always the name of the dll - so that's no help. The m_lpCmdLine is always blank so that's no help either. Is there a way to do this?

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                Even though MFC's DllMain() is calling your app's InitInstance() method, can you not use GetProcess() or GetProcessId()?


                "One must learn from the bite of the fire to leave it alone." - Native American Proverb

                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