I have this C ActiveX API (don't have the sources just the binaries):
// \param a [out] Variant holding a byte array
// \param b [out] Reference to a longlong (Signed 64-bit)
// \param c [out] Reference to a short
short foo(variant* a, longlong* b, short* c);
It's working fine in C#:
//auto-generated import:
short foo(ref object a, ref long b, ref short c);
test {
object a=null;
long b=0;
short c=0;
foo(a,b,c); => OK
}
NOK in Delphi 2010 (Note that {??Int64}OleVariant is added by the Delphi import tool):
//auto-generated import:
function foo(var a: OleVariant;
var b: {??Int64}OleVariant;
var c: Smallint): Smallint;
procedure Test;
var
a, b: OleVariant;
c: Smallint;
begin
foo(a,b,c); => **EOleSysError 'Type mismatch' exception**
end;
You can use predefined WinAPI types:
// C definition
short foo(variant* a, longlong* b, short* c);
// Delphi definition
function foo(var a: OleVariant;
var b: LongLong;
var c: Smallint); Smallint;
procedure FooTest;
var
a: OleVariant;
b: LongLong;
c, RetVal: ShmallInt;
begin
Retval := foo(a, b, c);
end;
LongLong
is defined in Windows.pas
, along with many, many other WinAPI compatible types. (At least they're in the Windows
unit up through Delphi XE; XE2 may have relocated some of them due to cross-platform and 64-bit related relocations.)
// Windows.pas definition (Delphi 2010)
type
LONGLONG = int64;
As David keeps mentioning in the comments below, longlong
isn't a standard C++ datatype. However, based on the comments related to the parameters in your update, it's exactly what the C++ developer intended it to be, and therefore the WinAPI definition is compatible (and retains the same name for consistency for documentation purposes).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With