How can I register COM dll on Pocket PC?
October 28th, 2004 by Andrey Yatsyk

Question

My Pocket PC doesn’t have regsvr32 utility. How can I register my COM dll on a Pocket PC device?

Answer

Pocket PC SDK contains a small utility regsvrce.exe for any supported processor. This utility is a replacement for desktop regsvr32.
regsvrce.exe
I am annoyed to enter full name of dll library so I created a registration utility that could display a tree of dll files and you should only select file you want to register. You can download this utility there (regsvr.zip) for ARM devices and x86 emulator.
regsvr.exe
If you want to register or un-register COM dll from code you need to call DllRegisterServer or DllUnregisterServer functions from dll you want to register. You can copy-paste the following code:

//for registration
HMODULE hLib = ::LoadLibrary(strLib);
if(hLib == 0) {
return FALSE;
}
HRESULT (STDAPICALLTYPE *pDllRegisterServer)();
(FARPROC&)pDllRegisterServer = ::GetProcAddress(hLib, _T("DllRegisterServer"));
if(pDllRegisterServer == NULL) {
::FreeLibrary(hLib);
return FALSE;
}
if(FAILED(pDllRegisterServer ())) {
::FreeLibrary(hLib);
return FALSE;
} else {
::FreeLibrary(hLib);
return TRUE;
}

//for unregistration
HMODULE hLib = ::LoadLibrary(strLib);
if(hLib == 0) {
return FALSE;
}
HRESULT (STDAPICALLTYPE *pDllUnregisterServer)();
(FARPROC&)pDllUnregisterServer = ::GetProcAddress(hLib, _T("DllUnregisterServer"));
if(pDllUnregisterServer == NULL) {
::FreeLibrary(hLib);
return FALSE;
}
if(FAILED(pDllUnregisterServer())) {
::FreeLibrary(hLib);
return FALSE;
} else {
::FreeLibrary(hLib);
return TRUE;
}

Usually registration and un-registration are performed during installation stage. It is possible to declare all libraries that should be registered in installer .inf file. The key CESelfRegister is used for that.

Related resources:

Section: COM/ActiveX

(Discuss in forum)

Leave a Reply