Re: Help please: Trouble getting a value back from COM.
Robert Hastings <[email protected]>
| Newsgroups | gmane.comp.windows.devel.jawin |
|---|---|
| Message-ID | <JAWIN%[email protected]> |
---------------------------
Darrin,
You might try jSegue. It's another SF project that I'm involved with that
uses a different approach to the same basic problem. The marshalling in
jSegue uses plain JNI. I'm certain that jSegue supports [out] BSTR *
parameters, because there is a JUnit test specifically for this case.
It's structured a little differently. If you have defined a coclass in the
typelib named CValidateLogin with a default interface of IValidateLogin then
you should be able to use code like this:
IValidateLogin iLogin = new CValidateLogin();
String[] retArray = new String[1];
iLogin.Garbage("InputString", 5, retArray);
System.out.println(retArray[0]);
If you don't have a coclass, then you can use
COM.CreateInstance
If you find issues with the documentation please let me know and I'll
update.
Robert
-----Original Message-----
From: Discussion of Java/Win32/COM integration with Jawin
[mailto:[email protected]] On Behalf Of Darrin Smith
Sent: Friday, June 04, 2004 11:42 AM
To: [email protected]
Subject: Re: [JAWIN] Help please: Trouble getting a value back from COM.
I think Jawin has some problems even after the correction.
Here is what I tried:
In the header file:
STDMETHOD(Garbage)(BSTR InputString, int InputInt, BSTR* returnString);
In the cpp file:
STDMETHODIMP CValidateLogin::Garbage(BSTR InputString, int InputInt,BSTR*
returnString)
{
*returnString = CString(_T("blah")).AllocSysString();
return 0;
}
In the idl file:
interface IValidateLogin : IDispatch{
[id(1), helpstring("method ValidateLogin")] HRESULT ValidateLogin
(BSTR UserName, BSTR Password, BSTR Domain, BSTR Server, BSTR* GroupRet);
[id(2), helpstring("method Garbage")] HRESULT Garbage([in]BSTR
InputString, [in]int InputInt, [out]BSTR* returnString);
I then called it like this:
GUID loginGUID = new GUID("{CAAB21D7-C41D-45F9-A610-9ADCAF448161}");
IValidateLogin iLogin = new IValidateLogin(loginGUID);
String[] retArray = new String[20];
iLogin.Garbage("InputString", 5, retArray);
On the last line, it gives me a Type Mismatch error upon execution
(everything compiles of course):
org.jawin.COMException: 80020005: Type mismatch.
at org.jawin.marshal.GenericStub.dispatchInvoke0(Native Method)
at org.jawin.marshal.GenericStub.dispatchInvoke(GenericStub.java:84)
at org.jawin.DispatchPtr.invokeN(DispatchPtr.java:473)
at org.jawin.DispatchPtr.invokeN(DispatchPtr.java:433)
...