I don't know the API you are calling but I would have thought they should
have declared it just as var RepBuffer; rather than var RepBuffer : Integer;

Rather than pass the address of the structure typecast as an integer, you
really want to pass the address of the structure, which is what the var is
all about.

To avoid changing their source you could try:
type
  PInteger = ^Integer;

begin
  ...
  SetRequestBufferDirect(MyBufLen,^PInteger(@MyStruct),Success);
  ...
end;

This way you are getting the address of MyStruct, casting it to a pointer to
integer, and then dereferencing it (which would essentially give you the
first four bytes of MyStruct), except you are then passing it as a var
parameter, so you are passing the pointer to MyStruct.
Worth a crack anyway.
  Andrew Cooke.



> -----Original Message-----
> From: Neil Anderson [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, February 03, 1999 3:54 PM
> To:   Multiple recipients of list delphi
> Subject:      [DUG]:  Typelib translation ?
> 
> Hi 
> 
> Could someone verify that Delphi 4.02 has imported and translated the
> typelib correctly:
> The part that is still puzzling me is the translation of ReqBuffer, I am
> sure the application is asking for an address to a structure, I have
> passed the address of the structure typecast as an integer to get the
> code to compile. The results have not been promising :(
> 
> This is code cut from a typelib viewer :
> [
>   odl,
>   uuid({F080A41A-28E0-11D2-80B6-00A0C92296F1}),
>   helpstring("ISogDirectBufferAccess Interface")
> ]
> interface ISogDirectBufferAccess {
>   [helpstring("method SetRequestBufferDirect")] HRESULT _stdcall
> SetRequestBufferDirect(
>           [in] long ReqBufferLen, 
>           [in, out] long* ReqBuffer, 
>           boolean* Success);
>   [helpstring("method GetReplyBufferDirect")] HRESULT _stdcall
> GetReplyBufferDirect(
>           [in] long RepBufferLen, 
>           [in, out] long* RepBuffer, 
>           boolean* Success);
> };
> 
> This is the Delphi transalated Code from the imported typelib:
> 
>   ISogDirectBufferAccess = interface
>     ['{F080A41A-28E0-11D2-80B6-00A0C92296F1}']
>     function SetRequestBufferDirect(ReqBufferLen: Integer; var
> ReqBuffer: Integer; 
>                                     var Success: WordBool): HResult;
> stdcall;
>     function GetReplyBufferDirect(RepBufferLen: Integer; var RepBuffer:
> Integer; 
>                                   var Success: WordBool): HResult;
> stdcall;
>   end;
> 
> 
> --------------------------------------------------------------------------
> -
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to