Forum Moderators: coopster
<?php
define ("MB_OK", 0);dl('php_w32api.dll') or die ("can't load w32api");
w32api_register_function("User32.dll", "MessageBoxA", "long");
MessageBoxA(NULL, "sample text", "msg box title", MB_OK);
?>
What I need is some advice or pointers to tutorials, which show how
to invoke the standard windows open dialog box.
I have the following code which runs but doesn't open a dialog box.
w32api_register_function("comdlg32.dll", "GetOpenFileNameA", "bool");
GetOpenFileNameA();
Any advice appreciated.
Many thanks.
This function is EXPERIMENTAL. The behaviour of this function, the name of this function, and anything else documented about this function may change without notice in a future release of PHP. Use this function at your own risk.
Since that is on all of them, they may not work. I also noticed a comment on one of the functions
use w32api_register_function to register your function and then simply call the function you registered just like you would call any normal PHP function.
Which is what I assume you are doing. Given the experimental nature of these functions I would think playing around with them will be necessary. The lack of user notes also makes it a little difficult.
Anyone else?
If you still want to proceed....
This is how I would do it, based on what I did in another Windows language. Basically, take a careful look at that parameters of the function (in the .h file). Tell PHP the pointer to a struct is a "string". You'll need to pass a string who's characters exactly match the low-level memory layout of this structure. That means converting integers to 4-byte binary values (little endian of course), string parts to fixed length with null-terminators inside. It's difficult and dangerous.
But, just do a Google search for the function name, and you'll find tips for other languages, which you can apply to PHP. I can't see many other people doing it in PHP, since the dialog pops up on the server exclusively.
Now, reboot your machine, because you probably corrupted your memory pool if you played with Win32 functions that take complicated paramaters.