|
I have successfully made a DCOM client and server, the client can call functions on the server. My trouble is trying to use MFC to create a connection point so that the server can call a function on the client.
On the client side I created a class ISimpCliAuto derived from COleDispatchDriver that has the exposed functions of the server. This class has a clsid, IID_ISimpCliAuto.
On the server side I have the following macros in the header file of the exposed class, CSimpServDlgAutoProxy:
BEGIN_CONNECTION_PART(CSimpServDlgAutoProxy, Alert)
CONNECTION_IID(IID_ISimpCliAuto)
END_CONNECTION_PART(Alert)
DECLARE_CONNECTION_MAP()
In the SimpServDlgAutoProxy.cpp I have the macros
BEGIN_CONNECTION_MAP(CSimpServDlgAutoProxy, CCmdTarget)
CONNECTION_PART(CSimpServDlgAutoProxy, IID_ISimpCliAuto, Alert)
END_CONNECTION_MAP()
On the client side I call CoCreateInstanceEx() and get an LPUNKNOWN m_pUnkServ. I call m_pUnkServ->QueryInterface() to get an LPDISPATCH which I can use in AttachDispatch(LPDISPATCH) and call exposed functions on the server side. I do not call m_pUnkServ->Release() at this point.
The problem occurs when I attempt to use m_pUnkServ in AfxConnectionAdvise(m_pUnkServ,...). The failure occurs within at the call
LPCONNECTIONPOINTCONTAINER pCPC;
HRESULT hr = m_pUnkServ->QueryInterface(IID_IConnectionPointContainer,(LPVOID*)&pCPC);
The hr indicates "No such interface supported." This is the result locally as well as over a network. The interface in question I think is the connection point container. But isn't all that supported by the macros above in the server? What am I doing wrong?
|
|
|
|
|
Hi,
I am passing a BSTR as an argument in a connectionpoint method. Everything is working fine except that when the BSTR is received by the client, it just gets the first character of the string.
Does anyone know how to solve this?
Thanks...
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
|
|
|
|
|
Is this a UNICODE or ANSI BSTR ?
Darka [ Xanya]
"I am not a slave to a god that doesn't exist."
|
|
|
|
|
By definition, a true BSTR can only be UNICODE.
Steve S
Developer for hire
|
|
|
|
|
Yes, but you can have ANSI ones too!
regards,
Darka [ Xanya]
"I am not a slave to a god that doesn't exist."
|
|
|
|
|
Not one that's strictly automation compatible; however, there doesn't seem to be anything anywhere in the documentation that says you absolutely can't, since a BSTR is a length-counted block of memory.
Steve S
Developer for hire
|
|
|
|
|
A BSTR which store only ANSI Text. Do you have a solution? If so, could you please share it.
Thanks.
-- modified at 2:03 Friday 13th October, 2006
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
|
|
|
|
|
Could you post a small code sample ?
Darka [ Xanya]
"I am not a slave to a god that doesn't exist."
|
|
|
|
|
Hello HakunaMatada,
Email me directly :
bio_lim_2004@yahoo.com
I have a COM app sample which receives a BSTR as an event parameter.
- Bio.
|
|
|
|
|
Thanks Bio, but I got the answer. There was a problem with the String conversion from BSTR to CString. A foolish mistake. Once I figured it out, it started working fine.
One question I would like to ask though is, Is there any limit to the number of characters that can be passed via a BSTR in COM? I mean does it make any difference if I passed a string with 1000000 words? Will it be reliable?
Thanks once again.
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
|
|
|
|
|
Hello HakunaMatada,
Congratulations on discovering the solution to your problem
Concerning the max length of a BSTR : yes there is a limit. Recall that a BSTR is not a NULL-terminated string. The length of the contents of a BSTR is actually stored inside a 4-byte unsigned long value. This 4-byte length indicator is stored in memory immediately before the start of the first byte of the BSTR.
Therefore, the max number of BYTES that can be contained inside a BSTR is 4294967295.
- Bio.
|
|
|
|
|
|
I am trying to recover my permanently deleted outlook mails through coding
I know that der r many software available in the market that can do so
But i want to do it through coding
I know it is done using MAPI's
I am able to import messages when they r present in inbox through code
but facing difficuly in recovering deleted messages
can anybody just help me in this
|
|
|
|
|
question:
In my application. I host the browser Activex control and i wanna instead default context menu with
custom menu when user right-click a img.
I override the ShowContextMenu function, in this function, i wanna get the href url before IMG tag like->
<a href="URL"><IMG src="..."></IMG></a>
I had Queried much Interface by ShowContextMenu's param pdispReserved, but none of them can get the url.
how can i do? thx.
aaaaaaaaaaaaaaaaaaabbbbbbbbbbccccccccccccccc
|
|
|
|
|
Hi,
I'm developing a Web Service Client that invokes a method that require a parameter defined in a complexType. I have only a wsdl where this type is defined. This client must be written in C++ (using Visual Studio 6.0). I'm developing a test in JScript, but it returns a error "SoapMapper:Saving SoapMapper Param_Ent_Cons_Saldo_MT failed no such interface..."
My code in ASP:
<br />
var obj1 = new ActiveXObject ("MSSOAP.SoapClient30");<br />
obj1.ClientProperty("ServerHTTPRequest") = true;<br />
obj1.MSSoapInit(caminho,"Cons_Saldo_Consignado_MIService","Cons_Saldo_Consignado_MIPort");<br />
var retorno = bj1.Cons_Saldo_Consignado_MI(parametros);<br />
The definition of the type in WSDL:
<br />
<xsd:complexType name="Param_Ent_Cons_Saldo_DT"><br />
<xsd:sequence><br />
<xsd:element name="Param_Entrada"><br />
<xsd:annotation><br />
<xsd:appinfo source="http://sap.com/xi/TextID"<br />
>b5593d80435411db8f4acd980a011ad5</xsd:appinfo><br />
</xsd:annotation><br />
<xsd:complexType><br />
<xsd:sequence><br />
<xsd:element name="BUKRS"><br />
<xsd:annotation><br />
<xsd:appinfo source="http://sap.com/xi/TextID"<br />
>b5593d81435411dbc619cd980a011ad5</xsd:appinfo><br />
</xsd:annotation><br />
<xsd:simpleType><br />
<xsd:restriction base="xsd:string"><br />
<xsd:maxLength value="4"/><br />
</xsd:restriction><br />
</xsd:simpleType><br />
</xsd:element><br />
<xsd:element name="PERNR"><br />
<xsd:annotation><br />
<xsd:appinfo source="http://sap.com/xi/TextID"<br />
>b5593d82435411dbc803cd980a011ad5</xsd:appinfo><br />
</xsd:annotation><br />
<xsd:simpleType><br />
<xsd:restriction base="xsd:string"><br />
<xsd:maxLength value="8"/><br />
</xsd:restriction><br />
</xsd:simpleType><br />
</xsd:element><br />
<xsd:element name="EMPORI"><br />
<xsd:annotation><br />
<xsd:appinfo source="http://sap.com/xi/TextID"<br />
>b5593d83435411db89aacd980a011ad5</xsd:appinfo><br />
</xsd:annotation><br />
<xsd:simpleType><br />
<xsd:restriction base="xsd:string"><br />
<xsd:maxLength value="6"/><br />
</xsd:restriction><br />
</xsd:simpleType><br />
</xsd:element><br />
<xsd:element name="VALBEN" minOccurs="0"><br />
<xsd:annotation><br />
<xsd:appinfo source="http://sap.com/xi/TextID"<br />
>b5593d84435411dbc680cd980a011ad5</xsd:appinfo><br />
</xsd:annotation><br />
<xsd:simpleType><br />
<xsd:restriction base="xsd:decimal"><br />
<xsd:totalDigits value="15"/><br />
<xsd:fractionDigits value="2"/><br />
</xsd:restriction><br />
</xsd:simpleType><br />
</xsd:element><br />
<xsd:element name="TIPBEN" minOccurs="0"><br />
<xsd:annotation><br />
<xsd:appinfo source="http://sap.com/xi/TextID"<br />
>b5593d85435411dbb07ecd980a011ad5</xsd:appinfo><br />
</xsd:annotation><br />
<xsd:simpleType><br />
<xsd:restriction base="xsd:string"><br />
<xsd:maxLength value="6"/><br />
</xsd:restriction><br />
</xsd:simpleType><br />
</xsd:element><br />
<xsd:element name="SALDIS" minOccurs="0"><br />
<xsd:annotation><br />
<xsd:appinfo source="http://sap.com/xi/TextID"<br />
>b5593d86435411db8d2bcd980a011ad5</xsd:appinfo><br />
</xsd:annotation><br />
<xsd:simpleType><br />
<xsd:restriction base="xsd:decimal"><br />
<xsd:totalDigits value="15"/><br />
<xsd:fractionDigits value="2"/><br />
</xsd:restriction><br />
</xsd:simpleType><br />
</xsd:element><br />
<xsd:element name="VALUTI" minOccurs="0"><br />
<xsd:annotation><br />
<xsd:appinfo source="http://sap.com/xi/TextID"<br />
>b5593d87435411db80cfcd980a011ad5</xsd:appinfo><br />
</xsd:annotation><br />
<xsd:simpleType><br />
<xsd:restriction base="xsd:decimal"><br />
<xsd:totalDigits value="15"/><br />
<xsd:fractionDigits value="2"/><br />
</xsd:restriction><br />
</xsd:simpleType><br />
</xsd:element><br />
<xsd:element name="SALSUF" minOccurs="0"><br />
<xsd:annotation><br />
<xsd:appinfo source="http://sap.com/xi/TextID"<br />
>c6303f60481711db8f71dd6f0a011ad5</xsd:appinfo><br />
</xsd:annotation><br />
<xsd:simpleType><br />
<xsd:restriction base="xsd:string"><br />
<xsd:maxLength value="1"/><br />
</xsd:restriction><br />
</xsd:simpleType><br />
</xsd:element><br />
<xsd:element name="SUCESSO" minOccurs="0"><br />
<xsd:annotation><br />
<xsd:appinfo source="http://sap.com/xi/TextID"<br />
>35265b2044e411dbb07bffe20a011ad5</xsd:appinfo><br />
</xsd:annotation><br />
<xsd:simpleType><br />
<xsd:restriction base="xsd:string"><br />
<xsd:maxLength value="1"/><br />
</xsd:restriction><br />
</xsd:simpleType><br />
</xsd:element><br />
<xsd:element name="MENSAG" minOccurs="0"><br />
<xsd:annotation><br />
<xsd:appinfo source="http://sap.com/xi/TextID"<br />
>b5593d88435411dbadfacd980a011ad5</xsd:appinfo><br />
</xsd:annotation><br />
<xsd:simpleType><br />
<xsd:restriction base="xsd:string"><br />
<xsd:minLength value="73"/><br />
</xsd:restriction><br />
</xsd:simpleType><br />
</xsd:element><br />
<xsd:element name="UNAME" minOccurs="0"><br />
<xsd:annotation><br />
<xsd:appinfo source="http://sap.com/xi/TextID"<br />
>b5593d89435411dbc3b4cd980a011ad5</xsd:appinfo><br />
</xsd:annotation><br />
<xsd:simpleType><br />
<xsd:restriction base="xsd:string"><br />
<xsd:minLength value="12"/><br />
</xsd:restriction><br />
</xsd:simpleType><br />
</xsd:element><br />
<xsd:element name="SENHA" minOccurs="0"><br />
<xsd:annotation><br />
<xsd:appinfo source="http://sap.com/xi/TextID"<br />
>b5593d8a435411db8db9cd980a011ad5</xsd:appinfo><br />
</xsd:annotation><br />
<xsd:simpleType><br />
<xsd:restriction base="xsd:string"><br />
<xsd:minLength value="12"/><br />
</xsd:restriction><br />
</xsd:simpleType><br />
</xsd:element><br />
</xsd:sequence><br />
</xsd:complexType><br />
</xsd:element><br />
</xsd:sequence><br />
</xsd:complexType><br />
Anyone knows how pass this type in method call?
Thanks,
Guilherme Pires
|
|
|
|
|
Dear All,
I am doing a COM EXE program using ATL.
I have developed COM EXE. and now i am creating a client for that COM EXE, I getting HRESULT value as FAILED.
this is my code ....
/*****************************
hr=CoCreateInstance(CLSID_Product,NULL,CLSCTX_INPROC_SERVER,IID_IProduct,(void**)&pInface);
/******************
What it could be ? . I dont know how to do further.
Kindly, Can you help me ?.
|
|
|
|
|
This is not full code , ofcourse. Can you show it.
Just making sure, have you used, ::Coinitialize(NULL), before calling any COM function.
|
|
|
|
|
yes I used ....
hr=CoInitialize(NULL);
IProduct *pInface;
hr=CoCreateInstance(CLSID_Product,NULL,CLSCTX_INPROC_SERVER,IID_IProduct, (void**)&pInface);
if(SUCCEEDED(hr))
{
printf("Success COM inside");
pInface->Display(Str,RetStr);
}
CoUninitialize();
|
|
|
|
|
Hello Sakthiu,
Aside from the fact that the third parameter to CoCreateInstance() is CLSCTX_INPROC_SERVER whareas your COM server is an EXE Server (the parameter value should be CLSCTX_LOCAL_SERVER), there are also many other possibilities (e.g. COM server not registered, proxy/client DLL not registered, etc).
It would also help tremendously if you let us know what the return value to CoCreateInstance() is (i.e. the value of "hr").
- Bio.
|
|
|
|
|
I manually call an application that normally gets a file from
drag and drop and displays some information about it.
Now i'm able to call the application, but
how can I specifiy the dragged file by hand?
All I know is to implemet an IdataObject,
witch contains a STGMEDIUM, and a FORMATETC.
I know that the application witch recieves the file,
get's the information from the hGlobal member of the
stgmedium struct.
Can anybody help me with this problem?
If you want I can post my sourcecode, too.
|
|
|
|
|
HI
Guys in my application in crystal reports, the following exception arises some times :
System.Web System.Runtime.InteropServices.COMException (0x80004005): The process cannot access the file because it is being used by another process.
at
CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(Export
Options pExportOptions, RequestContext pRequestContext)
at
CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequ
estContext reqContext)
at
CrystalDecisions.CrystalReports.Engine.FormatEngine.ExportToStream(ExportReq
uestContext reqContext)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.y(ExportOptions
1)
at
CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToStream(ExportF
ormatType formatType)
Can any one let me know the solution for this exception , plzzzzzz ASAP , thankx in advance.
|
|
|
|
|
Hi,
I developed an out-of-proc (exe) Server which has both 32 and 64 bit versions.
I developed a client at 32 bit. But when I try to run that client on 64 bit, CoCreateInstance fails giving Class-Not-Registered. For WOW64 bit, I passed CLSCTX option as CLSCTX_ACTIVATE_64_BIT_SERVER. Still the CoCreateInstance failed.
1. How can I call 64 bit exe server from 32 bit client? MSDN says this can be done, but I am not able to do this.
2. If I want to support WOW64 from the server side, what changes do I need to do in the server side? Do I have to install both 32 and 64 bit version exe in the 64 bit OS to support WOW64? Do I need to make seperate regitry entries?
Many thanks in Advance for the help...
|
|
|
|
|
Hey guys
My situation:
I started playing around with the excel object library in c# and became a bit confused when an error occured while trying to set the value of a specific range.
First I wanted to use a 2-dimensional array to fill the sheet with data in one step. But I had to break it down to more little parts (inserting row for row) in order to track down the source of this strange error.
When inserting row for row, i noticed some of them being inserted well and others were not.
The difference between the rows which were inserted without any error and those who weren't is the length of some strings which consist of more than 911 characters.
I already found out that inserting the single value into the cell works fine but as soon as i use an array to fill the sheet, it does not work anymore.
Now (and finally ) my question:
Is there any way to fill a excel sheet with a 2-dimensional array which contains strings longer than 911 chars with the set_Value method of a range object?
And if not - do you know any kind of workaround except for truncating the string to 911 chars?
Google wasn't very helpful (or i did not search for the right subject) and i just found some fellows having the same problem without any solution...
Thanks in advance,
mik
//edit:
I spent some more time in searching for a solution and found the following knowledge base article:
You may receive a "Run-time error 1004" error message when you programmatically set a large array string to a range in Excel 2003
I really don't want to believe that this actually is THE workaround - i even think its not a workaround at all. I would be glad to see a real workaround for this problem...
//second edit:
After googling like i never did before i found a google group post where a nice guy describes how to read a adodb recordset and fill the excel sheet with its data by using a QueryTable object. You also can use this to parse (tab-seperated) textfiles.
Here's the link - just check out the MSDN documentation for the different classes if you dont understand something (though QueryTable Class is barely documented...) -
Fill a Excelsheet with a QueryTable to work around the 911 character limitation
-- modified at 10:44 Monday 9th October, 2006
|
|
|
|
|
I'd activex control, having certain set of functions. Recently, I've added a new function to it, which i intend to exposed,
BEGIN_DISPATCH_MAP(CMyCtrl, COleControl)
DISP_FUNCTION(CMyCtrl, "fun1", fun1, VT_EMPTY, VTS_I4 VTS_I4)
DISP_FUNCTION(CMyCtrl, "newfunction", newfunction, VT_EMPTY, VTS_VARIANT)
END_DISPATCH_MAP()
I use this control at client code, using COledispatchDriver.
But problem is, now call to new function throws exception. i.e. it doesn't recognizes new function. COledispatchDriver is not able to invoke newly added function. I've registed changed activex.
Does anybody faced similar problem?
|
|
|
|
|
You have to re-import the ActiveX. Otherwise the classwizard generated wrapper class for your interface won't contain the new interface function.
By registering the component you simply add information to the registry, e.g. where the typelib for the component can be found. The registration procedure does not magically change any code in your client.
Of course you can "manually" add the new interface function to your client's interface wrapper class without re-importing the component. Have a look at how "funl" is handled and you should be able to figure it out. Just be careful to get the dispid and the argument list correct.
Hope this helps
--
Roger
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"No one remembers a coward!" - Jan Elfström 1998 "...but everyone remembers an idiot!" - my lawyer 2005 when heard of Jan's saying above
|
|
|
|