c# - Equivalent of C sharp "public IntPtr pHandle = IntPtr.Zero;" to Delphi "hp: Pointer" -
after research translated
phandle = intptr.zero;
to delphi
var phandle: pointer;
when break debug in delphi $314328
, when break debug on c sharp integer value 134180640
. can tell me how create right translation delphi?
the dll function calling in delphi is:
function saat_open(phandle: pointer): boolean; stdcall;
the c sharp function is:
[dllimport("rfidapi.dll", entrypoint = "saat_open")] [return: marshalas(unmanagedtype.i1)] public static extern bool saat_open(intptr phandle);
after research translated
phandle = intptr.zero;
to delphi
var phandle: pointer;
can tell me how create right translation delphi?
c# syntax allows initialize variable in same statement declare variable:
intptr handle = intptr.zero;
in delphi cannot initialize local variable declare it. need declare it, , initialize it:
var handle: pointer; .... handle := nil;
until assign local variable, of unmanaged type, value undefined.
however, if pass nil
saat_open
fail. function expects non null handle. so, initializing nil
won't help you. need more. need phone call function yields new handle. saat_tcpinit
. c# code show, initializes handle null value, needlessly. perhaps because saat_tcpinit
erroneously translated utilize ref
parameter handle, rather right translation out
parameter.
whilst above answers question asked, won't help solve problem. don't need null handle, need actual handle.
when break debug in delphi $314328, when break debug on c sharp integer value 134180640.
well, after phandle = intptr.zero
absolutely not see value 134180640
in c#. see value 0
. there must other code initializes handle. presumably phone call saat_tcpinit
. need create call. trust doing so.
the handle not have same value on subsequent executions of program. , need not have same value in each different program. handle dynamically allocated pointer , address variable 1 run next. nil worry if varies have observed. if saat_tcpinit
returns true
indicate success, handle value valid.
c# delphi pointers dll
No comments:
Post a Comment