Dll works in a C test script, but having problems passing value back to php

I have a simple dll which works in hescript if I have a procedure and simply display the value in a messagebox - simply returns an ip address in unsigned long integer format.

However when I try to convert my hescript procedure into a function so it returns the long integer back to php it is always returning 0 when instead I want it to return the value of HardwareIP(). The dll part is working fine, as tested it with a procedure and a simple call to messagebox.

My hescript is below… CardAddress is the external dll function.

function HardwareIP: Longint; stdcall; external “ipaddress-dll.dll” name ‘CardAddress’;

function TestDLL(void): Longint;
var TestDLL: Longint;
begin
TestDLL := HardwareIP();
end;

Thanks for any help. Not a criticism as such, but I suggest the help section needs more information on coding hescript functions, as nowhere could I find information on returning values.

Very close to getting it working using…

function HardwareIP: UnsignedLongint; stdcall; external “ipaddress-dll.dll” name ‘CardAddress’;

function TestDLL(void): UnsignedLongint;
begin
Result := HardwareIP();
end;

However Result is not been returned as an unsignedLongint - is there a way of doing that please? If I can get over this single problem, and maybe find a way of placing the .dll into the application, I have my application completed.

Thanks.

Just don’t know why it isn’t work… I have double checked my dll in another c program calling it, and def. returning a unsigned long integer value.

Just tried this alternative hescript function:

function HardwareIP: Cardinal; stdcall; external “ipaddress-dll.dll” name ‘CardAddress’;

function TestDLL(void): Cardinal;
begin
Result := HardwareIP();
end;

Using Delphi Pascal Cardinal type which at least via researching on google seems to suggest best for passing C based unsigned integer values, but on the php side is still returning the wrong value. No idea where I am going wrong. Please can someone help.

Thought it might be because Result variable is not unsigned, so it might be the php side, so tried this instead.

function HardwareIP: Cardinal; stdcall; external “ipaddress-dll.dll” name ‘CardAddress’;

function TestDLL(void): String;
begin
Result := IntToStr(HardwareIP());
end;

Using IntToStr to convert the hopefully returned unsigned long int from dll to a string, then return that to php, but still getting the wrong value. I have treble checked my dll in a test program, and there it is returning the right value… this logically suggests to myself the line:

function HardwareIP: Cardinal; stdcall; external “ipaddress-dll.dll” name ‘CardAddress’;

Is not handling unsigned long integers correctly… is there something wrong with this declaration. One other solution I could do is to recompile the ipaddress-dll and get it to send the return value into a local file, and then use php to read in that file, and use the string, but shouldn’t be necessary.

Any help would be useful. Thanks.

I don’t see any error in:

In next release, we upgraded the script engine to a new version, it should fix that problem.

Thanks for reply.

rofl… just found out I can do more or less exactly what my dll was doing with the simple PHP code…

$istatus=0;
if($hostname = gethostname()) {
$ip=gethostbyname($hostname);
if($ip!=$hostname) { $istatus=1; }
}

sets $istatus equal to 1 if a valid ip address is found, and on my pc returns an ip (in $ip) of 192.168.1.2 which is exactly what my ipconfig / dll produces.

Thank you for the follow-up. The topic will be closed soon.

This topic was automatically closed after 2 days. New replies are no longer allowed.