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. COM
  4. Query regarding Registeration and Unregisteration of COM dll.

Query regarding Registeration and Unregisteration of COM dll.

Scheduled Pinned Locked Moved COM
c++databasecomjsonperformance
10 Posts 2 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.
  • S Offline
    S Offline
    sandeepkavade
    wrote on last edited by
    #1

    hi all, i am having a COM dll and which is in memory. for unregistering it i use regsvr32 -u 'path'. and loaded the same dll from different location by regsvr32 'newpath'. All this i am doing through code in C++. But when i try to get the module path by calling GetModuleFileName() api it returns me the old path not the newly registered path. So is it because of the old dll is still in memory or something else and if its still in memory how to remove that from memory or am i missing something ???

    CPalliniC 1 Reply Last reply
    0
    • S sandeepkavade

      hi all, i am having a COM dll and which is in memory. for unregistering it i use regsvr32 -u 'path'. and loaded the same dll from different location by regsvr32 'newpath'. All this i am doing through code in C++. But when i try to get the module path by calling GetModuleFileName() api it returns me the old path not the newly registered path. So is it because of the old dll is still in memory or something else and if its still in memory how to remove that from memory or am i missing something ???

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      sandeepkavade wrote:

      But when i try to get the module path by calling GetModuleFileName()

      How do you call it? I mean, usually you haven't the HINSTANCE of a COM DLL.

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

      In testa che avete, signor di Ceprano?

      S 1 Reply Last reply
      0
      • CPalliniC CPallini

        sandeepkavade wrote:

        But when i try to get the module path by calling GetModuleFileName()

        How do you call it? I mean, usually you haven't the HINSTANCE of a COM DLL.

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

        S Offline
        S Offline
        sandeepkavade
        wrote on last edited by
        #3

        i am creating the object using CoCreateInstance(). but before that i am doing all the registeration and unregisteration. Does regsvr32 -u 'path' removes the dll from memory? i think thats what creating all problems?

        CPalliniC 1 Reply Last reply
        0
        • S sandeepkavade

          i am creating the object using CoCreateInstance(). but before that i am doing all the registeration and unregisteration. Does regsvr32 -u 'path' removes the dll from memory? i think thats what creating all problems?

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #4

          sandeepkavade wrote:

          i am creating the object using CoCreateInstance()

          And then how could you use GetModuleFileName?

          sandeepkavade wrote:

          Does regsvr32 -u 'path' removes the dll from memory?

          Nope. Registration means: put this f*ing COM class inside the registry (well, roughly speaking...). After registering a COM component, the COM runtime will load the registered DLL when asked by a client (i.e. whenever the client calls CoCreateInstance for such component). :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

          In testa che avete, signor di Ceprano?

          S 1 Reply Last reply
          0
          • CPalliniC CPallini

            sandeepkavade wrote:

            i am creating the object using CoCreateInstance()

            And then how could you use GetModuleFileName?

            sandeepkavade wrote:

            Does regsvr32 -u 'path' removes the dll from memory?

            Nope. Registration means: put this f*ing COM class inside the registry (well, roughly speaking...). After registering a COM component, the COM runtime will load the registered DLL when asked by a client (i.e. whenever the client calls CoCreateInstance for such component). :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

            S Offline
            S Offline
            sandeepkavade
            wrote on last edited by
            #5

            I am using GetModuleFileName() as fallows. void GetModulePath(const TCHAR *strModuleName, CString &strModulePath) { TCHAR modulePath[_MAX_PATH]; HMODULE hModule = GetModuleHandle(strModuleName); if( hModule != NULL ) { GetModuleFileName(hModule, modulePath, _MAX_PATH); TCHAR* slashPos = _tcsrchr(modulePath, _TCHAR('\\')); if (slashPos != NULL) *slashPos = NULL; // Terminate the string here. strModulePath = CString(modulePath); } else { // DO ERROR HANDLING HERE CString strError; GetErrorText(GetLastError(), strError); // Log the error; } }

            CPalliniC 1 Reply Last reply
            0
            • S sandeepkavade

              I am using GetModuleFileName() as fallows. void GetModulePath(const TCHAR *strModuleName, CString &strModulePath) { TCHAR modulePath[_MAX_PATH]; HMODULE hModule = GetModuleHandle(strModuleName); if( hModule != NULL ) { GetModuleFileName(hModule, modulePath, _MAX_PATH); TCHAR* slashPos = _tcsrchr(modulePath, _TCHAR('\\')); if (slashPos != NULL) *slashPos = NULL; // Terminate the string here. strModulePath = CString(modulePath); } else { // DO ERROR HANDLING HERE CString strError; GetErrorText(GetLastError(), strError); // Log the error; } }

              CPalliniC Offline
              CPalliniC Offline
              CPallini
              wrote on last edited by
              #6

              Well it looks correct. Have you checked corrensponding registry entries?

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

              In testa che avete, signor di Ceprano?

              S 1 Reply Last reply
              0
              • CPalliniC CPallini

                Well it looks correct. Have you checked corrensponding registry entries?

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                S Offline
                S Offline
                sandeepkavade
                wrote on last edited by
                #7

                Sorry for delayed reply. As per your suggestion i checked the registry entries but i havent seen any problems in that they are getting updated before and after unregistering/registering.

                CPalliniC 1 Reply Last reply
                0
                • S sandeepkavade

                  Sorry for delayed reply. As per your suggestion i checked the registry entries but i havent seen any problems in that they are getting updated before and after unregistering/registering.

                  CPalliniC Offline
                  CPalliniC Offline
                  CPallini
                  wrote on last edited by
                  #8

                  Can't you include some debugging info (i.e. output to debugger, to file, ...) in your COM DLL to distinguish between the two ones at runtime? :)

                  If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                  This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                  In testa che avete, signor di Ceprano?

                  S 1 Reply Last reply
                  0
                  • CPalliniC CPallini

                    Can't you include some debugging info (i.e. output to debugger, to file, ...) in your COM DLL to distinguish between the two ones at runtime? :)

                    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                    S Offline
                    S Offline
                    sandeepkavade
                    wrote on last edited by
                    #9

                    Yps, i am running debug viewer and the logs say that its refering to the old path.

                    CPalliniC 1 Reply Last reply
                    0
                    • S sandeepkavade

                      Yps, i am running debug viewer and the logs say that its refering to the old path.

                      CPalliniC Offline
                      CPalliniC Offline
                      CPallini
                      wrote on last edited by
                      #10

                      Hence you have loaded object path conflicting with registry one? I'm sorry but can only suggest you using Oleview tool to get additional info. :)

                      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                      In testa che avete, signor di Ceprano?

                      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