w32api passing string argument

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
  I'm using PHP 4.3.3 in CLI on Win XP SP1. I use the _experimental_
w32api. It seems to work quite fine yet I cannot pass a string argument
to any of my dll functions :

1) Load the w32api extension :
if (!dl("php_w32api.dll")) {
 echo "Erreur : Impossible de chager le module php_w32api

2) Register the dll functions into the win32 class
$api = new win32;
$api->registerfunction("int CIALArtPrixClient(string AR_Ref,string
CT_NUM,int C
atTarif,int AG_NO1,int AG_NO2,double &RESULTAT) From cbodbc32.dll");

3) Call the function
$ess->api->CIALArtPrixClient($ar_ref, $ct_num,2,0,0,$a);

The CIALArtPrixClient function is meant to retrieve the price of the
article 'AR_Ref' for the client 'CT_NUM' from a database. AG_NO1 and
AG_NO2 are to be ignored as they are numeric constants (I managed to
pass decimal values to some other functions). The last argument,
RESULTAT, is a reference to a double where to store the result (it also
works fine with another function).

When I try to run this code, the PHP script engine crashes (ending up
with a nice winxp 'send report' msgbox).

Does someone have any idea about how to pass a string as argument to a
dll exported function ?


Mohamed Rambil

Re: w32api passing string argument

Quoted text here. Click to load it

The manual notes that support for these functions is no longer
guaranteed. However, this quick test works OK on 4.3.4:

$api = new win32;
$api->registerfunction("long sndPlaySound (string a, int b) From
$api->sndPlaySound("c:\winnt\media\The Microsoft Sound.wav", 0);

I'd just suggest checking the argument names and types for the DLL
function very carefully as I doubt you will get much help from PHP if
there are any errors.


Re: w32api passing string argument

  In fact the example you give works. Must be a type mismatch between
the PHP value and the DLL one or maybe a type size mismatch.

Anyway, thanks a lot


Site Timeline