Page 1 of 1

Locating Win32api

Posted: Wed Sep 22, 2010 9:48 pm
by griffinmt
I am just getting back to using php for some basic maintenance functions on my systems, and took a look at using the win32api functions (just what I want!). But it would seem that win32api is no longer supplied with php (5.3.3) for windows binaries.

Can anyone help me find it, or explain why is is not a good choice??

Thanks

Re: Locating Win32api

Posted: Thu Sep 23, 2010 3:09 am
by requinix
Try to use COM instead.

What kind of "maintenance"?

Re: Locating Win32api

Posted: Thu Sep 23, 2010 5:12 pm
by griffinmt
For example, reorganizing sets of pics (jpg) across two servers based upon exif content info. A task that is 'scheduled' to run in the middle of the night.

Doing application specific backups across LAN and compressing/decompressing the files on the fly.

etc

Also, could you post an example of connecting to a network share using COM? I can't figure out where to start!!!

Re: Locating Win32api

Posted: Thu Sep 23, 2010 9:05 pm
by requinix
griffinmt wrote:For example, reorganizing sets of pics (jpg) across two servers based upon exif content info. A task that is 'scheduled' to run in the middle of the night.
Okay, but why do you need the Windows API for that?
griffinmt wrote:Doing application specific backups across LAN and compressing/decompressing the files on the fly.
Ditto.
griffinmt wrote:Also, could you post an example of connecting to a network share using COM? I can't figure out where to start!!
As long as whoever PHP is running as (NetworkService, IUSR, etc) has access to the share you can just... use it. Windows will do the connecting.

Code: Select all

$handle = fopen("\\\\server\\share\\path\\to\\file", "r");
There's no built-in way for doing authentication so... I don't know, I'd have to do some research. The same research you would do.

Re: Locating Win32api

Posted: Fri Sep 24, 2010 12:41 pm
by griffinmt
All of that is fine if you know what you want in advance.
I want to be able to enumerate all connected shares, connect to the desired share if not connected on each target system, enumerated all folders and files on these connections (along with creation/modified date etc), and so on.
Martyn

Re: Trying other ways!

Posted: Sun Sep 26, 2010 12:12 pm
by griffinmt
For now, thought I would try using some other 'methods.
The 'client' side is W7 and the 'server' side is WXP (on an isolated Lan).

On XP there is a share defined (//Gate/Wanderer) with full controll access by all users (network and local).

On W7 I am running both Apache2.2 and IE8 as the 'client'.

The following is a simple chunk of code being tested"

Code: Select all

$baseout = "\\\\Gate\\Wanderer";
$dir = dir($baseout);
$dir->close();
When I launch this, I get the following:
Warning: dir(\\Gate\Wanderer,\\Gate\Wanderer): Access is denied. (code: 5) in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\dev\BakMine.php on line 20
Warning: dir(\\Gate\Wanderer): failed to open dir: No error in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\dev\BakMine.php on line 20
Fatal error: Call to a member function close() on a non-object in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\dev\BakMine.php on line 21
The last error is kind of obvious, but what are the likely causes for the first error?