w32api passing string argument

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mrambil

    #1

    w32api passing string argument

    Hi,
    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_w32ap i.dll")) {
    echo "Erreur : Impossible de chager le module php_w32api
    (php_w32api.dll ).";
    exit;
    }

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

    3) Call the function
    $ar_ref="XVIS";
    $ct_num="OPALE" ;
    $ess->api->CIALArtPrixCli ent($ar_ref, $ct_num,2,0,0,$ a);

    The CIALArtPrixClie nt 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 ?

    Regards,

    Mohamed Rambil

  • Steve

    #2
    Re: w32api passing string argument

    [color=blue]
    > 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 :[/color]
    [color=blue]
    > $api = new win32;
    > $api->registerfuncti on("int CIALArtPrixClie nt(string AR_Ref,string
    > CT_NUM,int C
    > atTarif,int AG_NO1,int AG_NO2,double &RESULTAT) From cbodbc32.dll");[/color]

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

    dl("php_w32api. dll");
    $api = new win32;
    $api->registerfuncti on("long sndPlaySound (string a, int b) From
    winmm.dll");
    $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.

    ---
    Steve

    Comment

    • mrambil

      #3
      Re: w32api passing string argument

      Hi,
      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

      --
      Mohamed

      Comment

      Working...