|
Cheers, it worked a treat !!
|
|
|
|
|
Please help I am going crazy...
I'm using Windows 2000.
I make my ATL .EXE Server.
I make my C++ MFC client on the same machine.
run the code below via the client and get an E_NOINTERFACE error... what does this error actually mean...what do I have to change....? any ideas ?
Note that the .EXE does seem to have an Hello world interface exposed ? help me please, I've looked in OLEView and the registry and the .EXE object seems to be there. I've fiddled about with DCOMCNFG.EXE to try and configure it so that client/server run on the same machine and no such luck:
{
....
CoInitialize(NULL);
IExeServer* pIHelloWorld = NULL;
HRESULT hr = CoCreateInstance (CLSID_ExeServer,
NULL,
CLSCTX_LOCAL_SERVER, // note its a local.
IID_IExeServer,
reinterpret_cast(&pIHelloWorld));
if (hr == E_NOINTERFACE)
{
AfxMessageBox("CLASS_E_NOINTERFACE"); // this error is always
// there
}
if (FAILED(hr))
{
AfxMessageBox("FAILED");
CoUninitialize();
EndDialog(TRUE);
return TRUE;
}
CoUninitialize();
john s.
|
|
|
|
|
I'm using an ActiveX, a DCOM server and IIS.
On the IIS server (the one provided by Win2000), I have installed the DCOM server and put the ActiveX packaged in a cab file with the tlb and inf files.
I have created a html page where I use the ActiveX with some parameters:
- name of the DCOM server
- name of the alias to complete information give by the DCOM server
I go on a client machine on the same room, open IE and point to my page. IE download and install the ActiveX + DCOM TLB + interface marshalling.
The connection is ok, I can use the ActiveX and make request to the DCOM server.
I go on another client (not the same room and not the same domain, but the domains are trusted), I open IE and point to the page. IE download and install the ActiveX + DCOM TLB + interface marshalling.
The connection is KO and I can't create interface. More, it crashs the win2000 OS and I got a blue screen.
What is the safe way to use DCOM over Internet?
Thanks,
Bruno
|
|
|
|
|
Hello All,
Need help on Programming MSWord with Storage streams. I would like to create my own stream in a new document which will be saved by the user. Can i do that, plz help if anybody knows the solution ASAP. Thanx in advance.
|
|
|
|
|
Hi !
I have a VB app which runs an ActiveX (let's call it myActiveX1). This ActiveX has been developped in VB as well.
Then, my app runs several other ActiveXs, performing different tasks, and these ActiveX will have to refer to myActiveX1 in order to perform these tasks. From time to time, myActiveX1 will raise an event that I want to be able to capture from the other running ActiveX.
I believe that my app, when running the other ActiveX, will have to pass them, by one way or another, a pointer (or something similar) to myActiveX.
I have no idea how I could do that in VB ! I definitely don't want to instanciate a new myActiveX in each running ActiveX.
Thank you for your help !
Jerome
|
|
|
|
|
Can a object set to call a function from within a Win32 .dll be considered a COM object? What exactly are the requirements for something being termed a COM object, is it only language independence? Thanks.
Nick Parker
|
|
|
|
|
Properly supporting the IUnknown interface is basically the only requirement.
There are other requirements that make it compatible with languages like VB and VBScript, but they are not necessary in order to call your object a COM object.
If there are any other questions, or you want more detail feel free to ask.
|
|
|
|
|
A COM object implements at minimum the IUnknown interface and has the proper vtable layout in memory (as defined in the COM spec). There are also rules regarding querying interfaces, for example a QI for IUnknown must always return the same value.
--Mike--
It's hammer time!
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan and Jamie Salé.
|
|
|
|
|
The program, in C++, is sending a call to a DCOM object installed on a remote NT machine, and am trying to return a Safearray of float (as SAFEARRAY **ppfloatarray), have set that parameter as [in,out], (plus other parameters before this as [in]). Client is running Windows 98. On the client end, the data is not being written back to the passed-in safearray, and HRESULT returned is 8002000D, array is locked.
How is the client and server to be set up to do this? My solution was to try various combinations for the flags in the fFeatures member of the safearray, also to try setting the array to locked or unlocked before it was sent and before it was returned from server. I have a debug text file written, so I know that the DCOM object is executing, and the correct values are written to the safearray and are there just before it returns.
David Spain, C++ Applications Programmer
|
|
|
|
|
Hi David,
Can you put parts of your code in this forum? Specially those parts where
you are accessing and unaccessing the SAFEARRAY. It will be better if you
can also give us the portion of the IDL that describes the prototype of the
interface method where you are having the problem.
With best regards,
Sayan
(sayanmukherjee@indiatimes.com)
|
|
|
|
|
Ok, here is the code in question:
I was wanting to return a safearray of BSTR, but was having trouble with that, so thought maybe it had to do with the pointers, so tried float safearray, but is having same problem. This is the code with float safearray: >>> psaFloatReturn is the safearray in question <<<
IDL code:
[
object,
uuid(13AE8E35-3726-11D6-9913-000102476F95),
dual,
helpstring("IRemoteServerDisp Interface"),
pointer_default(unique)
]
interface IRemoteServerDisp : IDispatch
{
[id(2), helpstring("method Method2")] HRESULT Method2([in] BSTR sName, [in] SAFEARRAY(float) *psafloatAr1, [in] SAFEARRAY(VARIANT_BOOL) *psaBoolAr, [in] SAFEARRAY(float) *psafloatAr2, [in] long cnt, [in] float singlefloat1, [in] float singlefloat2, [in,out] SAFEARRAY(float) *psaFloatReturn, [out,retval] long* errcode);
};
--------------------
CoClass method:
STDMETHODIMP CCoRemoteServer::Method2(BSTR sName, SAFEARRAY **psafloatAr1, SAFEARRAY **psaBoolAr, SAFEARRAY **psafloatAr2, long cnt, float float1, float float2, SAFEARRAY **psaFloatReturn, long* errcode)
{
.
.
.
float HUGEP *pfloatTemp;
long val = SafeArrayAccessData(*psaFloatReturn, (void HUGEP**)&pfloatTemp);
float sldk = 3.0f;
for(int q=0; q<count; q++)
="" {
="" sldk="" +="1.0f;" test="" values
="" pfloattemp[q]="sldk;
" }
="" safearrayunaccessdata(*psafloatreturn);
="" safearraylock(*psafloatreturn);="" ???
="" *errcode="S_OK;
" return="" s_ok;
}
---------------
client="" code:
passed="" in:="" cstring="" sname,="" int="" cnt,="" float*="" pfloatarray1,="" bool*="" pboolarray,="" pfloatarray2,="" float="" float1,="" float2,="" long*="" errcode
{
="" safearraybound="" sab;
="" sab.llbound="0;
" sab.celements="cnt;
" safearray*="" psafloatreturn="SafeArrayCreateVector(VT_R4," 0,="" cnt);
="" initialize="" other="" parameters="" here
="" **="" safearray="" **
="" safearraylock(psafloatreturn);
="" tempfloat="new" float[cnt];
="" psafloatreturn-="">pvData = tempfloat;
SafeArrayLock(psaFloatReturn);
// call to DCOM object
BSTR bstrName = sName.AllocSysString();
HRESULT hResult =
m_pRemoteServer->Method2(bstrName, &psafloatar1, &psaBoolAr, &psafloatar2, cnt, float1, float2, &psaFloatReturn, errcode);
SysFreeString(bstrName);
SafeArrayDestroy(psafloatar1);
SafeArrayDestroy(psafloatar2);
SafeArrayDestroy(psaBoolAr);
bool ret = false;
if(SUCCEEDED(hResult))
ret = true;
if(psaFloatReturn!=NULL)
SafeArrayDestroy(psaFloatReturn);
delete []tempfloat;
}
About the count in initializing and returning, I know that the count on both ends is the same and matches the cnt variable given here, so is not an issue of writing past array boundaries.
Thanks in advance for any help.
David Spain, C++ Applications Programmer
|
|
|
|
|
No need for anyone to spend any more time on this --
Sorry if anyone spent time on this, I think there is code on this website in the articles that would help me. In the COM section, "STL Compliant Class for SafeArrays", the code returns safearrays from a COM object, which was my problem. There may be other articles as well. I will look at that to find out what I am doing wrong, so no need for anyone to look at this any further, thanks for the effort.
David Spain, C++ Applications Programmer
|
|
|
|
|
I want to incoporate vbscript and jscript in my MFC application. What is the correct method of implementing IAcitveScriptSite and IActiveScriptSiteWindow with ATL form VS.NET ??
Thanks
Michael
|
|
|
|
|
I have a UART driver (Remon Spekreijse made 97(!)) and when i toggle with suspend/resume a thread created in the UART driver I get unhandled exception messages when in release mode. It works if I just toggle once (I create the thread and then suspend it) but if I suspend it again I get the "unhandled exception". Maybe the driver is missing some code...I'm not an expert on the threading part, what should I look for in my code??
And also, does someone know were to find a good working UART driver that is newer that the one I have that is from 97 heh...
Dejan.
|
|
|
|
|
Using ATL/Windows 2000 I have created an .EXE ATL (simple object) COM object named EXEServer, I then created a (client) MFC .exe to try and create the .EXE ATL COM server object on the same machine using CoCreateInstance(....,CLSCTX_LOCAL_SERVER....), shown below - no luck !!!!
I get the HRESULT return error E_NOINTERFACE when I do a simple CoCreateInstance on the ATL .EXE COM object via the client. What is going wrong ? How can I fix this...?
I've checked both the registry AND OleViewer and the ATL COM ServerEXE IS there and seems to be active....what am I missing.....? please help me I am going crazy...
// The client MFC code...
BOOL CClientEXEDlg::OnInitDialog()
{
....
CoInitialize(NULL);
IExeServer* pIHelloWorld = NULL;
HRESULT hr = CoCreateInstance (CLSID_ExeServer,
NULL, CLSCTX_LOCAL_SERVER,
CLSCTX_,
IID_IExeServer,
reinterpret_cast<void**>(&pIHelloWorld));
BSTR bstrMsg = NULL;
void *pMsgBuf;
::FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
hr,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT ),
(LPSTR)&pMsgBuf,
0,
NULL );
AfxMessageBox((LPSTR)pMsgBuf);
if (hr == E_NOINTERFACE)
{
AfxMessageBox("CLASS_E_NOINTERFACE"); // this error is always
// there
}
if (FAILED(hr))
{
AfxMessageBox("FAILED");
CoUninitialize();
EndDialog(TRUE);
return TRUE;
}
else
{
m_edit = bstrMsg;
::SysAllocString(bstrMsg);
}
hr = pIHelloWorld->SayHello(&bstrMsg);
pIHelloWorld->Release();
UpdateData(FALSE);
// TODO: Add extra initialization here
CoUninitialize();
return TRUE;
}
john s.
|
|
|
|
|
I just started messing around with COM and am having this same exact problem. Are there extra settings for an out-of-process .exe server that I don't know about? Anyone?
|
|
|
|
|
Thank you!
I hope you could help me.
-----Method != Objective,COM != Panda-----
|
|
|
|
|
.....SetSite(IUnknown *pUnkSite)
{
IOleWindow *pOleWindow = NULL;
m_hWndParent = NULL;
if (SUCCEEDED(pUnkSite->QueryInterface(IID_IOleWindow, (LPVOID*)&pOleWindow)))
{
pOleWindow->GetWindow(&m_hWndParent);
pOleWindow->Release();
}
}
#define MOSTLY_LEAN_AND_MEAN
|
|
|
|
|
Thank you!
|
|
|
|
|
I am developing an ATL server that will run on several remote systems. How can I pick a server to connect to at run time? I know that I can use DCOM configuration to specify the implementation location before running my application but I want to allow a user to select from a list of computers or IP address that house the server while the client is running. How do I tell ATL where the server is located at run time?
Thanks.
|
|
|
|
|
Use CoCreateInstanceEx and pass it the machine name selected.
|
|
|
|
|
Thats great!
Thanks Mark.
|
|
|
|
|
Hi all,
I have a few (possibly nieve) questions regarding the efficiency of calls to in proc COM methods vs. standard C++ function calls.
I've inherited a project which had a master computer delegating some functionality to a few clients, using DCOM. We are now implementing all functionality in one monolithic app. The way I see it I have two options; either use the original COM dll's and invoke them as INPROC_SERVERs, or rip out the non-COM parts of the dll code and put it into C++ classes in my main app.
It would be easier to just use the dll's as they are - they work just fine, but I'm concerned about the efficency aspect. My app will be invoking methods in the order of 100 calls per second.
I would like to know some opinions as to what kind of performance hit I can expect in using COM vs. standard C++ function calls.
As I said, I have very little knowledge of COM, so this could be a rather dumb question
Any advice would be really appreciated.
TIA,
Pete
|
|
|
|
|
If you already have the interface in question, then COM is just like calling any virtual function.
Well, that is unless you are talking about invoking methods via IDispatch.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
>If you already have the interface in question, then COM is just like calling any virtual function
True only if calls are made within the same com apartment, otherwise they will be marshalled
|
|
|
|
|