|
when i try to return an integer Locally, everything goe's smooth.
but when i try it remotely i get the next number:-858993460
whatever the input is.
Plese Help!
|
|
|
|
|
Ok, did you look at the conversion? -858993460 is 0xCCCCCCCC which is usually what you find in uninitialized memory when running in debug mode.
Are you initializing the variable that you're returning? Just a guess.
J
|
|
|
|
|
Hi all,
When outputting a VARIANT from a COM interface member (as an [out] parameter, not [in, out]), should I call ::VariantClear() or ::VariantInit() on the output parameter before assigning to it? Or is this redundant/incorrect?
e.g.:
STDMETHODIMP MyFunc (/*[out]*/ VARIANT* pVal)
{
VariantInit (pVal); // ok?
pVal->vt = ....
...
}
cheers
NB
|
|
|
|
|
See sample app of COM Variant and Safearrays at
http://www.sellsbrothers.com/tools/CComSafeArray.zip
(from chris sells site)
|
|
|
|
|
Helllo everybody:
I have a DCOM server that returns an integer. This server runs on a win95 machine. When i connect everything goes fine but when i try to return the integer from the server, The client stops immidiatly. Is there enyone who ever had the same problem.
I preciate your Help..
|
|
|
|
|
Not knowing exactly what you are doing, it sounds as if the integer datatype is different between the client and the DCOM server. What kind of client are you using?
I have had this problem and I solved it by using the BSTR datatype. To do "pure COM" and being on the safe side, you should always pass BSTR:s as parameters, since they will be the same on both client and server side. This leads to a bit more of converting, but that's life
Best regards,
/_henrik
Henrik Sternberg,
Cambridge Technolgy Partners, Germany
www.ctp.com/ce
henrik.sternberg@ctp.nospam.com
(take away nospam)
|
|
|
|
|
Hi,
I have a DCOM application, where the component fires 8-10 events.
But all the events are similar in structure. (ie. they doesnt have any data associated with them).
The only difference is the event name.
So, I can easily use a single event to Notify all my events to
the client (And have some Parameter that distinguishes the event
to the client).
Now, my question is will this (using a single event in place of many events)
provide any PERFORMANCE benefits in a DCOM application ??
if yes, How ?? (some technical description will be appreciated)
anyway, the number of Network RoundTrips is going to be the same...
if no,
What will be a good COM programming practice in this situation.
(using a Single event or using different events)
Please somebody reply ...
I had posted this earlier, but got no response...
Thanks,
Firoz.
|
|
|
|
|
From a mantainability and debugging point of view combining all events into a single one would of course be more beneficial.
I don't believe I've seen any performance difference in using multiple events rather than a single one, as you said the round trips will be the same.
|
|
|
|
|
Firoz wrote:
the number of Network RoundTrips is going to be the same...
How do you figure? As I see it, DCOM needs to setup for each call. If you only call once, this setup (marshalling and whatnot) is only done once. If you do many calls, this setup needs to be done each time. Sure the amount of data (from your point of view) being sent is the same (1 x 10 events or 10 x 1 events), but I think you need to take into consideration the setup and teardown of the connection.
Please correct me if I'm wrong.
J
|
|
|
|
|
Hello, can somebody please help me:
i'm trying to write a string to a file serverside. and i want to get the string back. So i use the next function:
MIDL :write [in]BSTR message
cpp: HRESULT Write(BSTR message)
{
//code to write to a file on the server
}
can u please explane how the BSTR type works and how can i convert it to a normal string
|
|
|
|
|
CString str = _T("")
str = message;
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
|
One of the easiest way to use the BSTR type as normal string, in my opinion is
to use the compiler string type: _bstr_t
Use like this:
HRESULT Write(BSTR message)
{
_tprintf(TEXT("Message:%s\r\n", (LPCTSTR) _bstr_t(message));
}
You can look at the description for _bstr_t in MDSN for more help.
It can also convert ASCII string to Unicode. You may want to use conversion macro.
HRESULT Write(BSTR message)
{
USES_CONVERSION;
LPCTSTR lpszNormal = OLE2CT(message);
_tprintf(TEXT("Message:%s\r\n", (LPCTSTR) lpszNormal);
}
|
|
|
|
|
|
MultiByteToWideChar / WideCharToMultiByte or mbstowcs / wcstombs
|
|
|
|
|
There are 2ways to do this
The first method uses the OLE2T() for BSTR conversion to string.
The second method uses _bstr_t for conversion.
******************************************************#inclu#include <iostream.h>
#include <atlbase.h>
#include <comdef.h>
void main()
{
BSTR b=L"StringConversion"; //BSTR string
USES_CONVERSION; //First method of Conversion
cout<<"String :"<
|
|
|
|
|
Hi,All
I have a component(built using ATL) which supports outgoing interfaces.I want to use this component in MFC client.
When component fires an event i want to trap it and show the string which it sends in the modeless dialog box.
I dont know how to trap events in MFC client.
Can anybody help.
Regards
Tushar
|
|
|
|
|
Look at the MSDN KB article Q181845.
"HOWTO: Create a Sink Interface in MFC-Based COM Client".
regards,
Prem
|
|
|
|
|
Let me know if you get really stuck. Connection Points are just as unbelieably hard to handle in MFC applications as they are easy in VB. I can give you some details or examples if you need it.
|
|
|
|
|
We have implemented a com client in VC++ and it should communicate with server that developed in Delphi(.dll).
The Scenario is as folows
-------------------------------------
A button click on com client(vc) will invoke the com server (Delphi interface)(dialog based).
which will display a dialog were user can interact.Thus by the button click on VC client(dialog based) can invok multiple instances of delphi server.
Now we need to delete or close all the instances of com server with a single click in vc client (com client)
how it is possible ?.
Thanks in Advance
eby
|
|
|
|
|
Hello Eby,
What kind of server is it? (IN/OUT of process)
Can you provide more details?
Regards,
/_henrik
Henrik Sternberg, Consultant
Cambridge Technolgy Partners, Germany
www.ctp.com/ce
henrik.sternberg@ctp.nospam.com
(take away nospam)
|
|
|
|
|
Hi,
Since the Client invokes the server application,
u could have a the interface pointers stored in a
list and close all of them when ever u want to.
But this sounds probably too easy or may be i am not
aware of any additional details where u r facing problems
but from ur q's these should work.
regards,
Prem
|
|
|
|
|
Hi, I'm creating a worker thread in my ATL Object, and all the events seem to be getting handled right at the end. This has happened with many other people, and there are plenty of "What to do's" but not "How to do it".
So i'm trying to use a GlobalInterfaceTable which supposedly is the easiest and i'm trying it "last" (hoping this will be the last).. i tried using CoMarshalblahblah() but it still does the same thing w/o using those functions by just passing object through the LPARAM of CreateThread().
So anyways, it crashes in OLE32.exe when i call GetInterfaceFromGlobal(). It seems to get the Cookie fine and everything, but... when that function is called... it crashes.. and i dont know what i'm doing wrong... it's really frustrating cuz i've worked on this for a LONG TIME... so I think some source sample would be awesome. a few things:
********
# Where do i call CoCreateInstance() & GetInterfaceInGlobal()? From the function that creates the thread or from inside the thread? (i assumed it would be in my Function that creates the thread.
# I only have one of these objects right at the moment, so i just made the DWORD g_dwCookie "global", and I was passing the GIT through the LPARAM of CreateThread() and then calling
GetInterfaceFromGlobal(cookie, IID_ISpyder, (void**)Spy);
*for the record Spy is just a ISpyder *Spy = NULL; that's ok right?
Coolio, anyone lemme know if you can help me! Source or advise is cool! Thanks in advance!
~Timothy T. Rymer
www.digipen.edu
tim.xpertz.com
|
|
|
|
|
Hi,
1- If you make the variable global why passing it in the LPARAM of createThread ?
Normally , or you make a variable global or you pass the variable thru the LPARAM.
2- Normally, with multiple threads in a process a guy must protect the data with a critical section or with another sinchronization stuff ...
3-It's necessary to call CoCreateInstance and RegisterInterfaceInGlobal on the apartment where the object lives
4- It must be GetInterfaceFromGlobal(cookie, IID_ISpyder, (void**)&Spy)), you forgot the ampersand
5-You can call RevokeInterfaceFromGlobal from any apartment, but you must be certain that is the last apartment that makes use of the interface pointer
Hope this helps, best of luck
Joao Vaz
|
|
|
|
|
the only thing global is the cookie, i went ahead and made the GIT a member in my class, and passed it in through the LPARAM. but i didnt put my ampresand in there though. gonna try the stuff out now...
~Timothy T. Rymer
www.digipen.edu
tim.xpertz.com
|
|
|
|