Query regarding Registeration and Unregisteration of COM dll.
-
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 ???
-
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 ???
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 aCOM 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 -
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 aCOM 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 Clarkei 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?
-
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?
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 aCOM
component, theCOM
runtime will load the registeredDLL
when asked by a client (i.e. whenever the client callsCoCreateInstance
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 -
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 aCOM
component, theCOM
runtime will load the registeredDLL
when asked by a client (i.e. whenever the client callsCoCreateInstance
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 ClarkeI 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; } }
-
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; } }
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 -
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 ClarkeSorry 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.
-
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.
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 -
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 ClarkeYps, i am running debug viewer and the logs say that its refering to the old path.
-
Yps, i am running debug viewer and the logs say that its refering to the old path.
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