473,379 Members | 1,235 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,379 software developers and data experts.

How to call Win32 API functions ?

Hello

I would like to use php-cli as a sort of shell scripting language or
generic scripting language.

I have php 5.2 on WindowsXP and I would like to call Win32 API functions
like GetShortPathName.

How do I call API functions in PHP ? The documentation says there is an
extension called w32api, but if you read its documentation you find a
note stating the extension is now in PECL, and after browsing PECL you
find the extension is not there !

Apparently w32api used to work in PHP 4 but has not been ported to PHP5.

So how does one call API functions ? Nobody needs that ?

Can someone at least remove the w32api documentation from the php 5
manual ? Or keep only a note instead saying the extension has not been
ported ?

Thank you,
Timothy Madden,
Romania.
Jun 2 '08 #1
7 4148
NC
On May 18, 2:38 am, Timothy Madden <terminato...@gmail.comwrote:
>
So how does one call API functions ?
By writing custom PHP extensions in C/C++. In your particular case,
you will need to write an extension that would wrap around
kernel32.dll and expose its functions to PHP.

Alternatively, you can add PHP support to .Net and write your PHP
scripts in Visual Studio making use of everything available to a .Net
developer:

http://www.php-compiler.net/
Nobody needs that ?
Personally, I can't remember ever needing this. The built-in file
system functions have been adequate.
Can someone at least remove the w32api documentation from the php 5
manual ?
There is no such thing as "the PHP 5 manual". The PHP manual is not
version-specific and covers everything from the now-antiquated PHP 3
to the now-in-development PHP 6.

Cheers,
NC
Jun 2 '08 #2
NC wrote:
On May 18, 2:38 am, Timothy Madden <terminato...@gmail.comwrote:
>So how does one call API functions ?

By writing custom PHP extensions in C/C++.
[...]
Alternatively, you can add PHP support to .Net
[...]
>Nobody needs that ?

Personally, I can't remember ever needing this. The built-in file
system functions have been adequate.
>Can someone at least remove the w32api documentation from the php 5
manual ?

There is no such thing as "the PHP 5 manual". The PHP manual is not
version-specific and covers everything from the now-antiquated PHP 3
to the now-in-development PHP 6.
[...]

I do not want Microsoft, so I do not want .Net. As far as I know you
have to pay for it, while php is free.

It is easier to write the script I need, the one that uses
GetShortPathName, in C++ than to write a php extension.

I would like to know if there is anybody else who needed to call some
Win32 API function from php, maybe from php-cli.

Thank you
Timothy Madden,
Romania
Jun 2 '08 #3
Timothy Madden wrote:
NC wrote:
>On May 18, 2:38 am, Timothy Madden <terminato...@gmail.comwrote:
>>So how does one call API functions ?

By writing custom PHP extensions in C/C++.
[...]
>Alternatively, you can add PHP support to .Net
[...]
>>Nobody needs that ?

Personally, I can't remember ever needing this. The built-in file
system functions have been adequate.
>>Can someone at least remove the w32api documentation from the php 5
manual ?

There is no such thing as "the PHP 5 manual". The PHP manual is not
version-specific and covers everything from the now-antiquated PHP 3
to the now-in-development PHP 6.
[...]

I do not want Microsoft, so I do not want .Net. As far as I know you
have to pay for it, while php is free.
I believe you can download the SDK for free.
It is easier to write the script I need, the one that uses
GetShortPathName, in C++ than to write a php extension.

I would like to know if there is anybody else who needed to call some
Win32 API function from php, maybe from php-cli.
If you really need that function, you could always call your program
within the php script:

<?php
$shortPath = exec('myproggy ' . escapeshellarg($longPath));
?>

Curtis
Jun 2 '08 #4
Timothy Madden <te**********@gmail.comwrote:
>
I do not want Microsoft, so I do not want .Net.
What are you talking about? You said you were looking for the Win32 API.
Who do think created that? Apple?
>As far as I know you have to pay for it, while php is free.
The .NET runtime is a free download. In fact, it's probably one of the
options waiting for you in Windows Update, if you don't already have it.
And you can fetch a Visual Studio 2008 C# compiler for free as well.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jun 2 '08 #5
On 20 Mai, 07:06, Tim Roberts <t...@probo.comwrote:
Timothy Madden <terminato...@gmail.comwrote:
I do not want Microsoft, so I do not want .Net.

What are you talking about? You said you were looking for the Win32 API.
Who do think created that? Apple?
As far as I know you have to pay for it, while php is free.

The .NET runtime is a free download. In fact, it's probably one of the
options waiting for you in Windows Update, if you don't already have it.
And you can fetch a Visual Studio 2008 C# compiler for free as well.
--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
Well if you have their C++ compiler they will not give you the C#
compiler
or something like that, and the license limits you to evaluation use
only.

Anyway I found WinBinder and with it I could call GetShortPathName.
Timothy Madden,
Romania
Jun 2 '08 #6
Timothy Madden <te**********@gmail.comwrote:
>On 20 Mai, 07:06, Tim Roberts <t...@probo.comwrote:
>Timothy Madden <terminato...@gmail.comwrote:
>I do not want Microsoft, so I do not want .Net.

What are you talking about? You said you were looking for the Win32 API.
Who do think created that? Apple?
>As far as I know you have to pay for it, while php is free.

The .NET runtime is a free download. In fact, it's probably one of the
options waiting for you in Windows Update, if you don't already have it.
And you can fetch a Visual Studio 2008 C# compiler for free as well.

Well if you have their C++ compiler they will not give you the C#
compiler or something like that,
Complete and utter nonsense.
>and the license limits you to evaluation use only.
Also utter nonsense. The Express Edition doesn't include all of the extras
from the paid editions, but there are no additional restrictions on what
you can do with it.

There's plenty to dislike about Microsoft, but please take the time to find
out the truth before spreading rumors.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jun 2 '08 #7
Greetings, Timothy Madden.
In reply to Your message dated Tuesday, May 20, 2008, 11:58:28,
Well if you have their C++ compiler they will not give you the C#
compiler or something like that, and the license limits you to evaluation
use only.
I see it as a clear case of "RTFM or STFU"...
Really, why guess if you can just read?
They even released Visual Studio Express IDE for free.
Not just compiler. (Commandline compiler were *free* for ages)
Anyway I found WinBinder and with it I could call GetShortPathName.
Yes, that's what I was about to suggest. Glad you've discovered it first.
--
Sincerely Yours, AnrDaemon <an*******@freemail.ru>

Jun 27 '08 #8

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

Similar topics

4
by: ZhangZQ | last post by:
Is it possible to dynamicaly to local and call a function in Win32 dll(not a ..net assembly dll) in C# at run time, for example, a C# program popup a dialogbox to let use input which Win32 dll to...
5
by: Bryan Parkoff | last post by:
Please provide me the information when it is not in the correct newsgroups. I have been using C and C++ language for a long time when it is time for me to learn Win32 API functions that they can...
0
by: Veli-Pekka Tätilä | last post by:
Hi, My first post here. I've found some serious accessibility flaws in the Python 2.4 docs and wish they could be rectified over time. I'm very new to Python and initially contacted docs at python...
7
by: Tim ffitch | last post by:
Hi I have created a VB dll file that contains common functions I use across various projects in VB, Access and Excel. Rather than have to code the functions in each I decided to use the dll...
6
by: Mark Jerde | last post by:
I need to call a Win32 DLL. The API supports both Windows and Linux, but I'm only concerned with Windows. I'd like advice whether I can use C# or whether I'll have to dust off my old C++ books. ...
5
by: Kurt Van Campenhout | last post by:
Hi, I am trying to get/set Terminal server information in the active directory on a windows 2000 domain. Since the ADSI calls for TS don't work until W2K3, I need to do it myself. I'm fairly...
28
by: Peter Olcott | last post by:
I want to double check my understanding about how the .NET framework works. From what I understand every call to the .NET framework is ultimately translated into one of more API calls, is this...
12
by: leaf | last post by:
Hi, How to call function at runtime, based on a struct that contains the information for the function call: struct func_to_call { int function_id; // function id to call unsigned int nparams;...
9
by: Allen | last post by:
The arguments of function is variable. Given function address, argument type and data, how to dynamically call the function? The following is pseudo code. int count = 0; int offset = 0; char...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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.