Verify for us what COM/DCOM options you have built into your OS.
Let's try some experiments.
A. Marshalling
1. Try a custom interface NOT DERIVED FROM IDispatch. I don't think that
IDispatch is marshalled. If I'm right about that, what you're trying to do
won't work except for an in-proc object or if you do your own marshalling.
2. Make the custom interface very simple with a single function returning an
parameter. Have it put something that you will recognize if it comes back
correctly in the integer pointer (like 0x12345678).
3. Make sure that you have QueryInterface, etc. implemented for you by
ATL/MFC.
B. DCOM Missing
1. Recode your object as an in-proc object in a DLL, again not inheriting
from IDispatch.
2. Changing CoCreateInstance, of course, see if you can get this to work.
your OS doesn't have DCOM in it.
Paul T.
Post by sta2002 via PocketPCJunkies.com1) out of process COM server
. filename : ComExeCE11.exe
. made by a project of WCE ATL COM AppWizard (EVC++ 4.0)
2) Proxy Stub for COM server
. filename : ComExeCE11PS.dll
. made by a project of WCE Dynamic-Link Library
3) COM client
. filename : Test_ComExeCE11.exe
. made by the project of WCE Application (EVC++ 4.0)
the following source codes are on ComExeCE11.exe and Test_ComExeCE11.exe
//===================================================
// COM server source
//----------------------------------------------------------------------------
---------------------------
// ComExeCE11.idl : IDL source for ComExeCE11.dll
//
// This file will be processed by the MIDL tool to
// produce the type library (ComExeCE11.tlb) and marshalling code.
//----------------------------------------------------------------------------
---------------------------
import "oaidl.idl";
import "ocidl.idl";
[
object,
uuid(E5DEE0DC-15C4-4EE8-AB6F-EFB9B0747B2C),
dual,
helpstring("IComExeCE11Ctrl Interface"),
pointer_default(unique)
]
interface IComExeCE11Ctrl : IDispatch
{
[id(1), helpstring("method Function")] HRESULT Function();
[id(2), helpstring("method _com_issue_errorex")] HRESULT
_com_issue_errorex
(HRESULT _hr1, IUnknown *pthis1, const GUID refiid1);
};
[
uuid(4B7E4501-9B22-4D5B-8241-2E11F2B993A3),
version(1.0),
helpstring("ComExeCE11 1.0 Type Library")
]
library COMEXECE11Lib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[
uuid(C163B931-E486-40B8-87E0-90A9AF9657B0),
helpstring("_IComExeCE11CtrlEvents Interface")
]
dispinterface _IComExeCE11CtrlEvents
{
};
[
uuid(0A9DF809-A18A-4846-AFBB-E7B26507355E),
helpstring("ComExeCE11Ctrl Class")
]
coclass ComExeCE11Ctrl
{
[default] interface IComExeCE11Ctrl;
[default, source] dispinterface _IComExeCE11CtrlEvents;
};
};
//----------------------------------------------------------------------------
---------------------------
// ComExeCE11.cpp : Implementation of WinMain
// Note: Proxy/Stub Information
// To build a separate proxy/stub DLL,
// run nmake -f ComExeCE11ps.mk in the project directory.
//----------------------------------------------------------------------------
----------------------------
#include "stdafx.h"
#include "resource.h"
#include "initguid.h"
#include "ComExeCE11.h"
#include "ComExeCE11_i.c"
#include "ComExeCE11Ctrl.h"
LONG CExeModule::Unlock()
{
LONG l = CComModule::Unlock();
if (l == 0)
{
#if _WIN32_WINNT >= 0x0400
if (CoSuspendClassObjects() == S_OK)
PostThreadMessage(dwThreadID, WM_QUIT, 0, 0);
#else
PostThreadMessage(dwThreadID, WM_QUIT, 0, 0);
#endif
}
return l;
}
CExeModule _Module;
BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_ComExeCE11Ctrl, CComExeCE11Ctrl)
END_OBJECT_MAP()
LPCTSTR FindOneOf(LPCTSTR p1, LPCTSTR p2)
{
while (*p1 != NULL)
{
LPCTSTR p = p2;
while (*p != NULL)
{
if (*p1 == *p++)
return p1+1;
}
p1++;
}
return NULL;
}
/////////////////////////////////////////////////////////////////////////////
//
extern "C" int WINAPI _tWinMain(HINSTANCE hInstance,
HINSTANCE /*hPrevInstance*/, LPTSTR lpCmdLine, int /*nShowCmd*/)
{
lpCmdLine = GetCommandLine(); //this line necessary for _ATL_MIN_CRT
//HRESULT hRes = CoInitialize(NULL);
// If you are running on NT 4.0 or higher or under Windows CE you can use
the following call
// instead to make the EXE free threaded.
// This means that calls come in on a random RPC thread
HRESULT hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED);
_ASSERTE(SUCCEEDED(hRes));
_Module.Init(ObjectMap, hInstance);
_Module.dwThreadID = GetCurrentThreadId();
TCHAR szTokens[] = _T("-/");
int nRet = 0;
BOOL bRun = TRUE;
LPCTSTR lpszToken = FindOneOf(lpCmdLine, szTokens);
while (lpszToken != NULL)
{
if (lstrcmpi(lpszToken, _T("UnregServer"))==0)
{
_Module.UpdateRegistryFromResource(IDR_ComExeCE11, FALSE);
nRet = _Module.UnregisterServer();
bRun = FALSE;
break;
}
if (lstrcmpi(lpszToken, _T("RegServer"))==0)
{
_Module.UpdateRegistryFromResource(IDR_ComExeCE11, TRUE);
nRet = _Module.RegisterServer(TRUE);
bRun = FALSE;
break;
}
lpszToken = FindOneOf(lpszToken, szTokens);
}
if (bRun)
{
hRes = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER,
REGCLS_MULTIPLEUSE);
_ASSERTE(SUCCEEDED(hRes));
MSG msg;
while (GetMessage(&msg, 0, 0, 0))
DispatchMessage(&msg);
_Module.RevokeClassObjects();
}
CoUninitialize();
return nRet;
}
//----------------------------------------------------------------------------
---------------------------
// ComExeCE11Ctrl.cpp : Implementation of CComExeCE11Ctrl
//----------------------------------------------------------------------------
---------------------------
#include "stdafx.h"
#include "ComExeCE11.h"
#include "ComExeCE11Ctrl.h"
/////////////////////////////////////////////////////////////////////////////
// CComExeCE11Ctrl
STDMETHODIMP CComExeCE11Ctrl::Function()
{
// TODO: Add your implementation code here
static int nCount = 0;
FILE *fp = NULL;
fp = fopen("\\temp\\out.txt", "a+");
if(fp != NULL)
{
fprintf(fp, "nCount = %d\r\n", nCount);
fclose(fp);
}
//AfxMessageBox(L"CComExeCE11Ctrl::Function() is called");
return S_OK;
}
STDMETHODIMP CComExeCE11Ctrl::_com_issue_errorex(HRESULT _hr1, IUnknown
*pthis1, const GUID refiid1)
{
// TODO: Add your implementation code here
return S_OK;
}
//----------------------------------------------------------------------------
---------------------------
// ComExeCE11.res
//----------------------------------------------------------------------------
---------------------------
HKCR
{
NoRemove AppID
{
{E465FB4B-3128-4895-9A8C-23EDB7779AFE} = s 'ComExeCE11'
'ComExeCE11.EXE'
{
val AppID = s {E465FB4B-3128-4895-9A8C-23EDB7779AFE}
}
}
}
//----------------------------------------------------------------------------
---------------------------
// ComExeCE11.res
//----------------------------------------------------------------------------
---------------------------
HKCR
{
ComExeCE11.ComExeCE11Ctrl.1 = s 'ComExeCE11Ctrl Class'
{
CLSID = s '{0A9DF809-A18A-4846-AFBB-E7B26507355E}'
}
ComExeCE11.ComExeCE11Ctrl = s 'ComExeCE11Ctrl Class'
{
CLSID = s '{0A9DF809-A18A-4846-AFBB-E7B26507355E}'
CurVer = s 'ComExeCE11.ComExeCE11Ctrl.1'
}
NoRemove CLSID
{
ForceRemove {0A9DF809-A18A-4846-AFBB-E7B26507355E} = s 'ComExeCE11Ctrl
Class'
{
ProgID = s 'ComExeCE11.ComExeCE11Ctrl.1'
VersionIndependentProgID = s 'ComExeCE11.ComExeCE11Ctrl'
ForceRemove 'Programmable'
LocalServer32 = s '%MODULE%'
val AppID = s '{E465FB4B-3128-4895-9A8C-23EDB7779AFE}'
'TypeLib' = s '{4B7E4501-9B22-4D5B-8241-2E11F2B993A3}'
}
}
}
//----------------------------------------------------------------------------
---------------------------
//===================================================
// COM Client source
//----------------------------------------------------------------------------
---------------------------
// Test_ComExeCE11.cpp : Defines the entry point for the application.
//----------------------------------------------------------------------------
---------------------------
#include "stdafx.h"
#import "..\ComExeCE11\ComExeCE11.tlb" no_namespace // sta2002
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
CLSID clsid;
IID IIDIComExeCECtrl;
HRESULT rc;
IComExeCE11Ctrl* pComCtrl;
if (CoInitializeEx(NULL, COINIT_MULTITHREADED)<0)
{
printf("CoInitializeEx() is fail\r\n");
getchar();
return -1;
}
else
{
printf("CoInitializeEx() is success\r\n");
}
rc = CLSIDFromProgID(OLESTR("ComExeCE11.ComExeCE11Ctrl.1"),&clsid);
if (FAILED(rc))
{
printf("Failure in call to CLSIDFromProgID\r\n");
getchar();
return -1;
}
else
{
printf("calling CLSIDFromProgID is success\r\n");
}
rc = IIDFromString(OLESTR("{E5DEE0DC-15C4-4EE8-AB6F-EFB9B0747B2C}"),
&IIDIComExeCECtrl);
if (FAILED(rc))
{
printf("Failure in call to IIDFromString\r\n");
getchar();
return -1;
}
else
{
printf("calling IIDFromString is success\r\n");
}
TCHAR szOutText[256] = {0,};
char chOutText[256] = {0,};
pComCtrl = NULL;
rc = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER, //CLSCTX_ALL,
//CLSCTX_LOCAL_SERVER
IIDIComExeCECtrl, (void**)&pComCtrl);
if (FAILED(rc))
{
sprintf(chOutText, "Failure in call to CoCreateInstance[error = %x]", rc);
printf("%s\r\n", chOutText);
getchar();
return -1;
}
else
{
printf("calling CoCreateInstance is success\r\n");
}
getchar();
return 0;
}
------------------------------------------------------------------------------
-------------------------
Post by Paul G. Tobey [eMVP]Then I'd say that you're asking for an interface to whatever object you've
created that the object doesn't have. Without seeing the client code, we
can't possibly guess what that might be.
Paul T.
[quoted text clipped - 145 lines]
--
Message posted via PocketPCJunkies.com
http://www.pocketpcjunkies.com/Uwe/Forums.aspx/wince-vc/201004/1