|
Hi,I have a MFC client to access COM server install in a COM+ app on another machine,and it seem runs well ,but during a long time it thow an error with code 0x80010005.there is an article on MSDN "INFO: COM Method Call in WM_PAINT Handler Returns 0x80010005" ,my code didn't call com server in OnDraw nor in WM_PAINT handler.but the phenomenon even go.
I am very puzzle and have no idea about it.
Help me please!
|
|
|
|
|
"It is illegal to call out while inside message filter", does this make sense?
|
|
|
|
|
Hello,
i am creating an EXE com server through ATLCOMAppWizard. i inserted a NEWAtlObject through insert->newatlobject,i selected simple object then i prefered custom interfaces in attributes and checked the option of support Error information & connection points. i added more interfaces to the object by adding code to .IDL file &compiled it & made necessary changes to cpp file .
finally when build the project i got everything successful & the message of successfully registered component.
i am facing problem to create a client to that EXE-server, i cann't create object via CoCreateInstance though i included MIDL-generated .h &_i.c files in the client code.
please help me in creating client to the above EXE-server.If possible please send a example of EXE-client code.
satish silla
Larsen & Tubro Ltd,
Mumbai.
|
|
|
|
|
What is the error?
Make sure the remote server has been registered in the registry.
Kuphryn
|
|
|
|
|
i have seen the coclass is registered in the registry under the key HKEY-CLASSES-ROOT\CLSID\ .also at the time of building the project the result showing registation successful. one thing that i can n't find the IID of interfaces under the key HKEY_CLASSES_ROOT\interfaces\.
i am also in doubt how to create a client to exe-servers.i won't face the same problem in DLL-servers.
thanking u for trying to answer me
|
|
|
|
|
I created a simple activeX control in VB that has a single method that raises an event and passes back three params in the event. I have modded a c++ ATL client app that I found here (THANKS!) that processes the event. When the third event parameter is specified as type "SINGLE" in VB and float in c++, the printf works correctly (returns 302,429.0,460.0). When I change the third param to type "Double" in bothe the control and the C++ client, the values seem to be corrupted (302, -107374176.0, 5.6e-315) - even seems to corrupt the 2nd param (a single). Is there something different about passing doubles versus singles?
vb Code:
<br />
Public Event paramsback(ByVal x As Long, ByVal y As Single, ByVal z As Double)<br />
<br />
Public Sub PassItIn(ByVal x As Long, ByVal y As Single, ByVal z As Double)<br />
<br />
RaiseEvent paramsback(x, y, z)<br />
<br />
End Sub<br />
C++ app:
<br />
#include "stdafx.h"<br />
#include <stdio.h><br />
<br />
#import "ABIG_VBOCXTEST.ocx" no_namespace named_guids<br />
<br />
CComModule _Module;<br />
<br />
interface CSink:public IDispEventImpl<0, CSink, &DIID___mytestcontrol, &LIBID_ABIG_VBOCXTEST, 6, 0><br />
{<br />
public:<br />
<br />
BEGIN_SINK_MAP(CSink)<br />
SINK_ENTRY_EX(0, DIID___mytestcontrol, 0x1, Onparamsback)<br />
END_SINK_MAP()<br />
<br />
HRESULT __stdcall Onparamsback(long x, float y,double z)<br />
{<br />
printf("Event = %d,%6.2f,%6.2g",x,y,z);<br />
<br />
return S_OK;<br />
}<br />
};<br />
<br />
void main()<br />
{<br />
CoInitialize(NULL);<br />
<br />
_Module.Init(NULL, GetModuleHandle(NULL));<br />
<br />
_mytestcontrolPtr server;<br />
<br />
server.CreateInstance(CLSID_mytestcontrol);<br />
<br />
CSink sink;<br />
<br />
sink.DispEventAdvise(server);<br />
<br />
server->PassItIn(302,429.0,460.0);<br />
<br />
sink.DispEventUnadvise(server);<br />
<br />
server.Release();<br />
<br />
<br />
_Module.Term();<br />
<br />
CoUninitialize();<br />
}<br />
stdafx.h:
<br />
<br />
#if !defined(AFX_STDAFX_H__70227B2B_B9C9_4FC9_A100_2619AB307158__INCLUDED_)<br />
#define AFX_STDAFX_H__70227B2B_B9C9_4FC9_A100_2619AB307158__INCLUDED_<br />
<br />
#if _MSC_VER > 1000<br />
#pragma once<br />
#endif // _MSC_VER > 1000<br />
<br />
#define _ATL_MAX_VARTYPES 16<br />
<br />
#include <atlbase.h><br />
extern CComModule _Module;<br />
#include <atlcom.h><br />
<br />
<br />
<br />
#endif // !defined(AFX_STDAFX_H__70227B2B_B9C9_4FC9_A100_2619AB307158__INCLUDED_)<br />
stdafx.cpp
<br />
#include "stdafx.h"<br />
|
|
|
|
|
|
Yes it can. But I can help you only with ATL - don't have a clue how to do it with MFC. The events are in fact standard methods as any other, so you have just to mark the parameter as [out] or [out,retval] . That's all in IDL.
But if you are using ATL, there's a little need to change the generated Fire_OnMyEvent method. Understanding what's going on inside the method is the key to the success
On beginning there's created a new array of CComVariant s. Later on, all parameters are copied(!) to this array. And you need to change exactly this behavior - there are several ways...
What you can use is instead of copying the value, use the already existing variant in an array and turn him to the reference to your out parameter (VT_BYREF flag can be handy). But any other method can be also usefull and working - it's up to you to decide how you want to do it.
|
|
|
|
|
Hi,
I am learner of COM Technology.I have written simple com object.It has 3 methods.I compiled it successfully.But the problem is I have written client program,it is showing errors.
i have included component's .h,_i.c files into client program
CoInitialize(NULL);
CoCreateInstance(..........);
what are the steps to follow to write COM Client program.
yakkalas
|
|
|
|
|
Did you register the COM server to registry? What is the error?
Kuphryn
|
|
|
|
|
hi,
yah registered COM Server to registry.
atlwin.h requires atlbase.h to be included first
|
|
|
|
|
Did you use the ATL wizard?
What is the error yu get?
R.Balachandran
|
|
|
|
|
I have created Arthematic simple object.
in Client program i write like this.
CoInitialize(NULL);
IArthematic *art;
CoCreateInstance(CLSID_Arthematic,NULL,CLSCTX_INPROC_SERVER,IID_Arthematic,reinterpret_cast<void**>&iu);
And when compiling, compiler shows atlwin.h require atlbase to be included first.
I have included Arthematic.h and MyCom_i.c files in my client program.
how can I get out of this and plz tell me how to write client program for a simple object.
|
|
|
|
|
Include the .h file that ATL's MIDL generated and the .h file from of the coclass.
Kuphryn
|
|
|
|
|
Here I have given a sample working code for a COM client
// COMClientDlg.cpp : implementation file
#include "stdafx.h"
#include "COMClient.h"
#include "COMClientDlg.h"
#include "COMServer.h"
#include "COMServer_i.c"
............................
............................
............................
HRESULT hr;
IMessage *msg;
hr = CoInitialize(0);
//initialize COM
if( SUCCEEDED(hr) )
{
hr = CoCreateInstance(
CLSID_Message,
NULL,
CLSCTX_INPROC_SERVER,
IID_IMessage,
(void **)&msg
);
if( SUCCEEDED(hr) )
{
msg->Show();
msg->Release();
}
else
{
AfxMessageBox("Cannot create COM object");
}
CoUninitialize();
//uninitialize COM
}
else
{
AfxMessageBox("Cannot initialize COM");
}
This code worked fine when I tested under an MFC dialog project.
The server was created as a DLL by the ATL wizard. While creating a simple object
the following options were selected.
Threading Model - apartment
Interface - dual
Aggregation - yes
If you still have trouble you can mail your code to me
R.BALACHANDRAN
|
|
|
|
|
You should use #import directive and smart pointers.
It makes everything simple for developing COM client.
For example, if you have COM object named Message then do the following:
#import "Message.tlb" no_namespace
void main()
{
CoInitialize(NULL);
try
{
IMessagePtr pMessage = IMessagePtr(__uuidof(Message));
pMessage->Method();
}
catch(_com_error &e)
{
HRESULT hr = e.Error();
}
CoUninitialize();
}
|
|
|
|
|
the MainFrame Menus of Active Document Server Application is dynamic created ;
so how can i make the container' embed Menu as same as the menu of active document server application ? What can i do it?
please help me ,thanks
|
|
|
|
|
Hello,
Can somebody point me out the differences between the webbrowser control and the internetexplorer object ?
What are the purpose of each one ?
Can you build the same applications with both ? Can they be embedded the same way ?
Is one control offering more features than the other, including non-visual features (like more cookies stuff...) ?
Thanks,
R. LOPES
Just programmer.
|
|
|
|
|
Hi,
I'm a novice in COM so my question is very easy.
I want to crete the COM server (INPROC_SERVER) with method like:
virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetStr(
/* [out][in] */ LPSTR lpcszStr) = 0;
STDMETHODIMP CAbc::GetStr(LPSTR lpcszStr)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// TODO: Add your implementation code here
char *mystr="string from COM";
lpcszStr=mystr;
return S_OK;
}
So, is it possible to return the string pointer from COM server?
Yours sincerely,
Alex Bash
|
|
|
|
|
Hi,
I'm a novice too. But I have had the same problem. So maybe I can give you a hint.
As far as I know the best solution is to use the BSTR data type. This is not very complicated. There are only some special functions that you have to use: SysAllocString, SysFreeString, SysStringLen and some other ones. You could do it like this:
IDL:
GetStr([out] BSTR* str)
Method implementation:
STDMETHODIMP CAbc::GetStr(BSTR* str)
{
//Allocate memory for the BSTR
str = SysAllocString("string for COM");
//Check wether allocation was successful
if(str) return S_OK;
else return E_FAIL;
}
And the caller:
...
BSTR myBStr;
HRESULT hr = Abc->GetStr(myBStr);
if(FAILED(hr)) damned();
else
{
//Now you've got the string
//Do with it what ever you want (but don't get rude...)
//You can use it like a LPSTR as far as I know
printf("My String: %s", myBStr); //example
SetDlgItemText(IDC_EDIT, myBStr); //example
//But now it is your responsability to free the memory!
SysFreeString(myBStr);
//That's it
}
...
I hope this was all correct. Try it. It should work.
But maybe someone else can tell you more or correct my posting.
|
|
|
|
|
Remember to pass in the COM interface function an address of BSTR and to dereference the pointer to a BSTR before assignment.
*str = SysAllocString("string for COM");
HRESULT hr = Abc->GetStr(&myBStr);
Kuphryn
|
|
|
|
|
what he says and what u answer..?? oooooooops..
[ It is possible to represent everything in this universe by using 0 and 1 ]
|
|
|
|
|
in an ocx how do i get the hinstance of the container? specifically, if a vb project is using the ocx, how would i get the parent (vb project) hinstance so i may access the resource file in th vb project?
shotgun
|
|
|
|
|
Hi,
I have a sample code in VB that I need to "translate" to VC++.
But I don't know how tu use safearrays.
Here is the VB code :
<br />
Dim pSafeArray As Variant<br />
pSafeArray = pBlock.SafeArray(0)<br />
' Loop through the SafeArray and set value to each pixel<br />
Dim I, J As Integer<br />
For I = 0 To pSize.X - 1<br />
For J = 0 To pSize.Y - 1<br />
pSafeArray(I, J) = I + J<br />
Next J<br />
Next I
pBlock is an object provided by the API I'm using
Could you help me ?
Thx,
Stephane
www.exotk.org
|
|
|
|
|
I'm trying to enumerate OLE and VB Controls of a other process. I've already found the Microsoft article (Q141414) about how to do this by using the IOLEClientSite Interface.
I've already sucessfully "entered" the process using dll injection methods, now I face the problem how to get a pointer to IOLeClientSite without using COleControl::GetClientSite() as described in the mentioned article.
Perhaps there is another method to enumerate controls I'm not aware of?
Thanks
Georg
|
|
|
|