CodeGuru
Earthweb Search
Forums Wireless Jars Gamelan Developer.com
CodeGuru Navigation
Member Sign In
User ID:
Password:
Remember Me:
Forgot Password?
Not a member?
Click here for more information and to register.

Become a Marketplace Partner

jobs.internet.com

internet.commerce
Partners & Affiliates
















RSS Feeds

RSSAll

RSSVC++/C++

RSS.NET/C#

RSSVB

See more EarthWeb Network feeds

Home >> Visual C++ / C++ >> Windows Programming >> CE >> COM


COM for eMbedded Visual C++ 3.0 ( Under Windows CE )
Rating: none

B. Manivannan (view profile)
November 8, 2001

Environment: eMbedded Visual C++ 3.0, Windows 2000, Windows CE Emulator (Handheld PC Pro)

To Run this application we must have installed eMbedded Visual C++ 3.0


(continued)



The Generation of the COM Server and the COM Client in embedded Visual C++ 3.0 is somewhat different than the Microsoft Visual C++ 6.0. It leads an error in the COM server while running the client. This Article resolves the error and achieves the Server functionality.

Generate the Server( CEServer.dll)

Generate the work space for the Server.

Step: 1

Step: 2

click finish.

Step 3:

Select Simple Object for the COM. Because we need simple COM object that supports in-proc server.

Click Next to select the interface name

Type Process in the field for short name. It automatically generates the Class name, Interface name etc as it was in Visual C++ 6.0.

Press OK. Now we have given the parameters how the COM object should be.

Build the Server dll. It builds successfully and does not give any error. We have generated the COM Server.

Generate the Client( CEClinet.exe)

Step 1:

Let the Client be a dialog based application,

The Design of the dialog is as shown in the figure.

Step 2:

Add the Server dll file path in stdafx.h file after #endif

#import "C:\\Program Files\\Windows CE Tools\\wce211\\MS HPC Pro
\\emulation\\hpcpro\\windows\\CEServer.dll" no_namespace

Note: In my system, the Windows CE Tools directory is in the Program Files. Try to modify according to your path.

Step 3:

Declare the pointer for the Process interface in the header file CEClientDlg.h,

CLSID clsid;
IProcess *m_pProcess;

Add the following lines in the OnInitDialog in CEClientDlg.cpp,

BOOL CCEClientDlg::OnInitDialog()
{
  CDialog::OnInitDialog();
  // TODO: Add extra initialization here
  HRESULT hr;
  hr = CLSIDFromProgID(OLESTR("CEServer.Process.1"),&clsid);
  if(FAILED(hr))
    MessageBox(NULL,_T("Prog id failed"), MB_OK);
  CoCreateInstance(clsid,
                   NULL,
                   CLSCTX_INPROC_SERVER,
                   __uuidof(IProcess),
                   (void**)&m_pProcess);

  if(m_pProcess == NULL)
    MessageBox(NULL,_T("interface pointer failed"), MB_OK);
  return TRUE; // return TRUE  unless you set the
               // focus to a control
}

Step 4:

Then call the function from the interface while the user clicks the button,
void CCEClientDlg::OnCallServer()
{
  m_pProcess->Show();
}

Compile the Client Project. You will get some error in the server in the CEServer.tli file.

That is,  error C2065: '_com_issue_errorex' :
  undeclared identifier.

This is the main difference while creating the COM in eMbedded Visual C++ 3.0. This error does not come in Microsoft Visual C++ 6.0. This article is mainly dedicated to solve this error and run the COM Client Successfully.

What to be done to resolve this problem
(The modification is in the CEServer.dll)

Add the definition or override the existing function.

Step 1:

Goto CEServer.idl file,

interface IProcess : IDispatch
{
   //Show function
   //Add this function declaration here
   [id(2), helpstring("method _com_issue_errorex")] HRESULT
            _com_issue_errorex(HRESULT _hr1,
                               IUnknown  *pthis1,
                               const GUID  refiid1);
};

Step 2:

Goto Process.h file,

Add the declaration ,

STDMETHOD(_com_issue_errorex)(HRESULT _hr1,
            IUnknown  *pthis1,
            const GUID  refiid1);

Step 3:

Goto Process.cpp file,

Add the definition,

STDMETHODIMP CProcess::_com_issue_errorex(HRESULT _hr1,
            IUnknown  *pthis1,
            const GUID  refiid1)
{
  AFX_MANAGE_STATE(AfxGetStaticModuleState())

  // TODO: Add your implementation code here

  return S_OK;
}

Rebuild all.

Again come to the COM Client and rebuild the client application.

Downloads

Download demo project (COM CE Server) - 30 Kb
Download demo project (COM CE Client) - 40 Kb

Tools:
Add www.codeguru.com to your favorites
Add www.codeguru.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed







RATE THIS ARTICLE:   Excellent  Very Good  Average  Below Average  Poor  

(You must be signed in to rank an article. Not a member? Click here to register)

Latest Comments:
How to solve OCX inclusion problem in WinCE Emulator - Legacy CodeGuru (06/06/2003)
with Events? - Legacy CodeGuru (01/09/2003)
How to make COM server run in Emulator? - Legacy CodeGuru (05/08/2002)
Embedded VB client for Embedded ATL Component. - Legacy CodeGuru (05/01/2002)
How to register the COM dll on PPC? - Legacy CodeGuru (04/12/2002)

View All Comments
Add a Comment:
Title:
Comment:
Pre-Formatted: Check this if you want the text to display with the formatting as typed (good for source code)



(You must be signed in to comment on an article. Not a member? Click here to register)


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
Avaya Article: Call Control XML - Powerful, Standards-Based Call Control
Tripwire Whitepaper: Seven Practical Steps to Mitigate Virtualization Security Risks
Internet.com eBook: The Pros and Cons of Outsourcing
Go Parallel Article: Scalable Parallelism with Intel(R) Threading Building Blocks
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
Go Parallel Article: James Reinders on the Intel Parallel Studio Beta Program
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
Go Parallel Article: Getting Started with TBB on Windows
HP eBook: Storage Networking , Part 1
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Go Parallel Video: Intel(R) Threading Building Blocks: A New Method for Threading in C++
HP Video: Is Your Data Center Ready for a Real World Disaster?
Microsoft Partner Portal Video: Microsoft Gold Certified Partners Build Successful Practices
HP On Demand Webcast: Virtualization in Action
Go Parallel Video: Performance and Threading Tools for Game Developers
Rackspace Hosting Center: Customer Videos
Intel vPro Developer Virtual Bootcamp
HP Disaster-Proof Solutions eSeminar
HP On Demand Webcast: Discover the Benefits of Virtualization
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Microsoft Download: Silverlight 2 Software Development Kit Beta 2
30-Day Trial: SPAMfighter Exchange Module
Red Gate Download: SQL Toolbelt
Iron Speed Designer Application Generator
Microsoft Download: Silverlight 2 Beta 2 Runtime
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
IBM IT Innovation Article: Green Servers Provide a Competitive Advantage
Microsoft Article: Expression Web 2 for PHP Developers--Simplify Your PHP Applications
Featured Algorithm: Intel Threading Building Blocks - parallel_reduce
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES