Re: Interfacing IDL and COM objects [message #79925] |
Fri, 13 April 2012 13:56  |
Jim Pendleton
Messages: 165 Registered: November 2011
|
Senior Member |
|
|
On Friday, April 13, 2012 8:15:57 AM UTC-6, rohit bhat wrote:
> Hi,
>
> I was trying to interface Import a COM object into IDL. I have no
> knowledge of COM but I do have the source code with me.
> There are a few methods defined with the keywords [propput]. I used
> IDL's SetProperty method and it worked on them.
>
> Then there are few methods that have nothing defined in them . Eg:
> GetInfo( In nIndex, BSTR _RPC_FAR *pStudy_Info )
> where Study_Info is a structure that has fields like
> {
> int nIndex
> char Pname[128]
> char Date [32]
> int Status
> char Description[128]
> char ID[128]
> }
>
> When I call this method in IDL, using Obj -> GetInfo, 0l, S
> 1. Error when I put S as "structure", "pointer to a structure" on the
> IDL side
> 2. Nothing returned when S is a "string", "byte" on the IDL side
>
> Does the presence of keywords like [retval], [in] make it easier for
> IDL to interface with COM?
> or
> Is it that IDL does not understand the datatype that COM sends? (non-
> compatibility with structures, pointers, strings)
>
> Please let me know.
>
> Thanks,
> Rohit
Just a guess, but what if you specify the parameter, on the IDL side, as a BYTARR() of the correct number of bytes? If this works, you'll need to use IDL's FIX function on the returned byte vector to extract your data, via the offset parameter and TYPE keyword.
Be careful of the definition for char in this context. Is it really a 1-byte C-style char or is it multibyte or Unicode?
|
|
|
Re: Interfacing IDL and COM objects [message #80146 is a reply to message #79925] |
Thu, 26 April 2012 11:21  |
rohit bhat
Messages: 4 Registered: August 2011
|
Junior Member |
|
|
On Apr 13, 4:56 pm, jimmyleependle...@gmail.com wrote:
> On Friday, April 13, 2012 8:15:57 AM UTC-6,rohitbhatwrote:
>> Hi,
>
>> I was trying to interface Import a COM object into IDL. I have no
>> knowledge of COM but I do have the source code with me.
>> There are a few methods defined with the keywords [propput]. I used
>> IDL's SetProperty method and it worked on them.
>
>> Then there are few methods that have nothing defined in them . Eg:
>> GetInfo( In nIndex, BSTR _RPC_FAR *pStudy_Info )
>> where Study_Info is a structure that has fields like
>> {
>> int nIndex
>> char Pname[128]
>> char Date [32]
>> int Status
>> char Description[128]
>> char ID[128]
>> }
>
>> When I call this method in IDL, using Obj -> GetInfo, 0l, S
>> 1. Error when I put S as "structure", "pointer to a structure" on the
>> IDL side
>> 2. Nothing returned when S is a "string", "byte" on the IDL side
>
>> Does the presence of keywords like [retval], [in] make it easier for
>> IDL to interface with COM?
>> or
>> Is it that IDL does not understand the datatype that COM sends? (non-
>> compatibility with structures, pointers, strings)
>
>> Please let me know.
>
>> Thanks,
>> Rohit
>
> Just a guess, but what if you specify the parameter, on the IDL side, as a BYTARR() of the correct number of bytes? If this works, you'll need to use IDL's FIX function on the returned byte vector to extract your data, via the offset parameter and TYPE keyword.
>
> Be careful of the definition for char in this context. Is it really a 1-byte C-style char or is it multibyte or Unicode?- Hide quoted text -
>
> - Show quoted text -
Jimmy,
Thanks for your reply. I tried sending a Byte array but it comes back
empty.
The funny part is even when I pass the first argument in IDL (which is
declared as an Int on the COM side), as a long, ulong, int, uint,
float, string, (anything)...it does not crash or give any error.
Does it mean that IDL or COM are not able to understand each-other
here?
( The first argument will always be less than a number I get from a
previous operation. Suppose a database has two employees and I query
through IDL-COM. Then, nIndex (first arguemnt) should be 0 or 1 in the
procedure
GetInfo( Int nIndex, BSTR _RPC_FAR *pInfo )
So, If I input anything more than that, even then it doesnt work. or
doesnt crash)
Thanks,
Rohit
|
|
|