Windows Mobile Developer Network Forum

Windows Mobile Developer Network Forum
It is currently Fri Jul 30, 2010 2:45 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 1 post ] 

Rate this article
1 0%  0%  [ 0 ]
2 0%  0%  [ 0 ]
3 0%  0%  [ 0 ]
4 0%  0%  [ 0 ]
5 0%  0%  [ 0 ]
Total votes : 0
Author Message
 Post subject: How can I register COM dll on Pocket PC?
PostPosted: Thu Oct 28, 2004 3:58 pm 
Offline
PPCDN Team

Joined: Tue Apr 01, 2003 6:28 pm
Posts: 229
Location: Saint-Petersburg, Russia
<h2>Question</h2> My Pocket PC doesn't have regsvr32 utility. How can I register my COM dll on a Pocket PC device?
<h2>Answer</h2> Pocket PC SDK contains a small utility regsvrce.exe for any supported processor. This utility is a replacement for desktop regsvr32.
<img alt="regsvrce.exe" src="/articles/images/regsvrce.gif" width="240" height="320">
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 (<a href="samples/regsvr.zip">regsvr.zip</a>) for ARM devices and x86 emulator.
<img alt="regsvr.exe" src="/articles/images/regsvr.gif" width="240" height="320">
If you want to register or un-register COM dll from code you need to call <i>DllRegisterServer</i> or <i>DllUnregisterServer</i> functions from dll you want to register. You can copy-paste the following code:
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;
}

Code:
//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 <i>CESelfRegister</i> is used for that.
<h2>Related resources:</h2>
<img src="http://www.pocketpcdn.com/images/bullet.gif" width="22" height="15"><a href="/sections/com.html">Section: COM/ActiveX</a>

_________________
Andrey Yatsyk


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group