|
Hi
I am reading about COM nowadays.
how can com achieve method calling between dlls which were coded different languages.
I mean every language has spesific calling convention mechanism.What is the solution to pass this problem?
I don't understan this issue.
And one more:
are there any more problems to call methods between dlls except calling conventions?
Regards.
|
|
|
|
|
COM methods use the __stdcall calling convention. COM compatible languages use the same __stdcall when calling COM methods. There are also various rules on parameter passing.
Steve
|
|
|
|
|
Hello.
I have a serious problem.
In the following codes, I always come to have false return.
Is there any problem in CLSID_UpdateServiceManager?
I have had a successful result by using VBScript, but VC++..
I'm looking forward to your answer.
///////// Always Fail /////////////////////////////////////////////
IUpdateServiceManager* pMgr;
hr = ::CoCreateInstance(CLSID_UpdateServiceManager, NULL, CLSCTX_INPROC_SERVER, IID_IUpdateServiceManager, (void**) &pMgr );
if (FAILED(hr))
{
m_pUnknown_Manager = NULL;
return false;
}
//////// Always Success ///////////////////////////////////////////
hr = ::CoCreateInstance(CLSID_UpdateSession, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (LPVOID*)&m_pUnknown_Session);
if (FAILED(hr))
{
return false;
}
|
|
|
|
|
It sounds like the object (CLSID_UpdateServiceManager ) doesn't implement the IUpdateServiceManager interface. I'd wager the HRESULT is E_NOINTERFACE . Try this to convince yourself:
IUnknown *pUnk;
hr = ::CoCreateInstance(CLSID_UpdateServiceManager, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, reinterpret_cast<LPVOID*>(&pUnk));
if (FAILED(hr))
{
return false;
}
IUpdateServiceManager *pMgr;
hr = pUnk->QueryInterface(IID_IUpdateServiceManager, reinterpret_cast<LPVOID*>(&pMgr));
if (FAILED(hr))
{
pUnk->Release();
return false;
}
pMgr->Release();
pUnk->Release();
It is also possible the object is being accessed cross apartment and the proxy-stub doesn't exist - The object does implement the interface but it can't be marshaled across to the client apartment.
Steve
-- modified at 4:10 Tuesday 21st March, 2006
|
|
|
|
|
Thank you for concern.
I tested the code you sent, but the result is the same as the one which I've already had.
For your reference, the value of hr was -2147221231
See you.
|
|
|
|
|
Yeah, but on which line of my code did it fail - There are comments that say what the problem probably is.
-2147221231 is 0x80040111 in hex (don't quote HRESULT s in decimal!) which has the symbolic name CLASS_E_CLASSNOTAVAILABLE.
Steve
|
|
|
|
|
It was my purpose to convert the following VBScript to VC++ source code.
http://windowssdk.msdn.microsoft.com/library/en-us/wua_sdk/wua/using_wua_to_scan_for_updates_offline.asp?frame=true
The above vbs worked well, but the conversion fell in difficulty just after starting.
I'd had an experience using CLSID_UpdateSession, so I was quite frustrated.
In your convenient time, please check this matter.
Thanks.
|
|
|
|
|
Can you post the value of hr?
Also the CLSIDs are different in both your cases. Please ensure that both these classes suport IUpdateServiceManager.
If the requested interface is not supported, hr should be equal to E_NOINTERFACE.
Have a great day ahead!
Regards,
Sohail Kadiwala
(My Blog - http://blogs.wdevs.com/sohail/[^])
modified 21-Apr-21 21:01pm.
|
|
|
|
|
Thank you for concern.
The value of hr is -2147221231
Have a good day!
|
|
|
|
|
In the debugger, type this into the watch window: "hresult,hr". Assuming that hresult is the variable holding your error code, the debugger will present a human readable form, if there is any. Otherwise, please do the people here a favor, and present your error codes in the forum, using the hexadecimal form.
|
|
|
|
|
Can anyone tell me what this macro is meant for, and where I should use it.
Thanks
|
|
|
|
|
|
:-OHi, all experts:
I tried to create a COM local server and a client using win32 console application winzard in VC++ 6. When the client started up, it active the server automatically. The client also connected to server and called interface functions successfully. But, how can I terminate the server from client, before the client ended itselt?
Thanks a lot!
REMY
|
|
|
|
|
With COM objects you shouldn't need to take any explicit action to terminate the server beyond the normal reference counting calls to AddRef and Release you (and/or your smart pointers) do on the object's interfaces.
Steve
|
|
|
|
|
Yes. I wrote the 'Release' member for COM SEVER just as following:
ULONG CExeComServerConsole0_0::Release()
{
long nRefCount = InterlockedDecrement(&m_nRef) ;
if (nRefCount == 0)
delete this;
return nRefCount;
}
But, How can I teminate the server process?
|
|
|
|
|
Ok, you’re talking from the point of view of implementing the server, that wasn't clear in your post. Typically a global reference count is maintained which all implemented COM object increment when they're constructed and decrement when they're destructed. IClassFactory::LockServer also increments or decrements it based on its parameter - References on class factories should not influence this count. When the count transitions to zero the server typically wait for a timeout - If there is no activity and the timeout expires CoSuspendClassObjects is called and we arrange for the application to exit. In short it's complicated. Use ATL and you don't have to worry about any of this.
Steve
|
|
|
|
|
Thank you! Steve
I wanted to know more about the auto-ending of Server. I created a ATL EXE COM SERVER and used a client to conneted and disconnected it. After a moment, in system process list, the ATL EXE process disappeared. But, I didn't know when the CoSuspendClassObjects was called. Could you tell me more details. I'm learning COM/ATL. Thank you very much!
Sincerely
REMY
|
|
|
|
|
Need help with passing a BYTE array in COM.
I think i have done it right but i only get the first byte passed.
Here is the idl:
interface ICOMtestObject : IUnknown
{
[id(1), helpstring("method GetData")] HRESULT GetData([out]ULONG *sz,[out,size_is(,*sz)]BYTE **data);
};
Here is the implementation in the COM server:
STDMETHODIMP CCOMtestObject::GetData(ULONG *sz, BYTE **data)
{
// TODO: Add your implementation code here
*data = (BYTE*)CoTaskMemAlloc( 5 * sizeof( BYTE));
(*data)[0]='T';
(*data)[1]='e';
(*data)[2]='s';
(*data)[3]='t';
(*data)[4]='\0';
*sz=5;
return S_OK;
}
Here is the implementation in the client:
HRESULT hr = m_objPtr.CoCreateInstance(L"Comtest.COMtestObject.1");
ULONG sz;BYTE *data;
hr = m_objPtr->GetData(&sz,&data);
The data array includes only the first byte.
Here are some sample code
http://forums.devx.com/attachment.php?attachmentid=1036
|
|
|
|
|
As i can see, you want to pass a string, right ? Why don't use a "COM-String" ?
[id(1), helpstring("method GetData")] HRESULT GetData([out, retval]BSTR* data);
If you want to pass a "real" array, why don't you use a "COM-Array" ?
[id(1), helpstring("method GetData")] HRESULT GetData([out, retval]SAFEARRAY* data);
|
|
|
|
|
Hello Johan,
Since your interface is non-Automation-compatible, did you build the corresponding Proxy/Stub DLL ?
I downloaded your source codes and did not notice any projects for a Proxy/Stub DLL.
This is necessary especially since your COM server is an EXE. I'm surprised that your client code can even successfully call GetData().
Best Regards,
Bio.
|
|
|
|
|
My mistake i forgot to compile the proxy-stub.
Thanks
|
|
|
|
|
Is there any difference of running web services in VS 2003 and 2005......
in VS 2003 i added my webservice through "add reference".
so iam getting Service class not found message...
Pllllz help me.......
Rgds
Suresh
|
|
|
|
|
Dear all,
Help! I want to do DCOM (ServicedComponent), but when I install the application proxy, it failed.
Can anyone help? I'm desperate now!
Thanks!
David Chan
|
|
|
|
|
How do I change the UUID of an existing ActiveX component? I have made a little changes to the component to add a few more functionalities. I now want to assign a new UUID to this control. How do I do this?
Regards,
Aljechin Alexander
|
|
|
|
|
I don't know of any way to do that through the IDE etc, but I think you can change it by hand:
First, create a backup of the entire project.
1- Create a new similar ActiveX component. Add a similar New ATL Object to it. Do not compile it.
2- Open both the new and old .IDL files and change every occurence of the old similar IDL 's GUID 's with the new ones.
3- Open both the .RGS files, and change all similar GUID 's with the new ones.
There may be easier ways. This is just one of them.
this is this.
|
|
|
|