473,382 Members | 1,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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_w32api.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->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
$ar_ref="XVIS";
$ct_num="OPALE";
$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 ?

Regards,

Mohamed Rambil

Jul 21 '05 #1
2 1716
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 : $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");


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->registerfunction("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

Jul 21 '05 #2
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

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Alex Vinokur | last post by:
Various forms of argument passing ================================= C/C++ Performance Tests ======================= Using C/C++ Program Perfometer...
5
by: kazack | last post by:
I am a little confused with code I am looking at. My c++ book does not go into passing a structure to a function so I pulled out a c book which does. and I do not understand the prototype verses...
3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
25
by: Victor Bazarov | last post by:
In the project I'm maintaining I've seen two distinct techniques used for returning an object from a function. One is AType function(AType const& arg) { AType retval(arg); // or default...
4
by: B Squared | last post by:
I'm trying to pass a string from the current html page to one I'm calling. I've read (in the O'Reilly text) this involves using "?", but there's no example. For example, given I have a standard...
3
by: sd2004 | last post by:
I am still learning, could someone show/explain to me how to fix the error. I can see it is being wrong but do not know how to fix. could you also recommend a book that I can ref. to ?...
4
by: Boris | last post by:
The PHP documentation at http://www.php.net/manual/en/ref.w32api.php says that W32api has been moved to the PECL repository and is no longer bundled with PHP as of PHP 5.1.0. After I finally found...
6
by: Andy Baker | last post by:
I am attempting to write a .NET wrapper for a C++ DLL file, but am having problems with passing strings as parameters. How should I be writing my C# function call when the C header file is...
18
by: sanjay | last post by:
Hi, I have a doubt about passing values to a function accepting string. ====================================== #include <iostream> using namespace std; int main() {
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.