Re: [PHP] Using DLL with PHP

2009-02-11 Thread Dan Shirah
 MAYBE a little closer to a solution!

//VB for Reference
Private Declare Function DTM_CONVDMSToMultiTIFF Lib D32_CONV.DLL _
(ByVal FullPathFrom As String, ByVal FullPathTo As String) As
Integer

Public Function hello(ByVal name As String) As String

hello = Hello  name  World!
End Function
Public Function DMStoTIFFconv(ByVal FullPathFrom As String, ByVal FullPathTo
As String) As String
Dim DMSconv As Integer
DMSconv = DTM_CONVDMSToMultiTIFF(FullPathFrom, FullPathTo)
End Function
//PHP Code
?php
function Hello() {
$new_com = new COM(DMStoTIFF.conv);
$output=$new_com-hello('Happy'); // Call the hello() method
echo $output; // Displays Hello World! (so this comes from the dll!)
$convert=$new_com-DMStoTIFFconv('C:\\TEST\\04186177.dms','C:\\TEST\04186177.tif');
}
Hello();
?

So, previously I was having issues calling the D32_CONV.DLL...
I think I am past that now.

If I comment out
$convert=$new_com-DMStoTIFFconv('C:\\TEST\\04186177.dms','C:\\TEST\04186177.tif');
the Hello Happy World text prints to the screen no problem.

But when I try to access the VB to call the actual DTM_CONVDMSToMultiTIFF
function I am getting one of two errors. I am either timing out, or getting
a message saying incomplete headers.

The D32_CONV.DLL file is a conversion library that will convert a file from
DMS format to TIF based on two parameters. Since this function is converting
a document, do you think my problem is trying to assign that to the $convert
variable instead of a file output location?


Re: [PHP] Using DLL with PHP

2009-02-11 Thread Andrew Ballard
On Wed, Feb 11, 2009 at 1:18 PM, Dan Shirah mrsqua...@gmail.com wrote:
  MAYBE a little closer to a solution!

 //VB for Reference
 Private Declare Function DTM_CONVDMSToMultiTIFF Lib D32_CONV.DLL _
(ByVal FullPathFrom As String, ByVal FullPathTo As String) As
 Integer

 Public Function hello(ByVal name As String) As String

hello = Hello  name  World!
 End Function
 Public Function DMStoTIFFconv(ByVal FullPathFrom As String, ByVal FullPathTo
 As String) As String
Dim DMSconv As Integer
DMSconv = DTM_CONVDMSToMultiTIFF(FullPathFrom, FullPathTo)
 End Function
 //PHP Code
 ?php
 function Hello() {
 $new_com = new COM(DMStoTIFF.conv);
 $output=$new_com-hello('Happy'); // Call the hello() method
 echo $output; // Displays Hello World! (so this comes from the dll!)
 $convert=$new_com-DMStoTIFFconv('C:\\TEST\\04186177.dms','C:\\TEST\04186177.tif');
 }
 Hello();
 ?

 So, previously I was having issues calling the D32_CONV.DLL...
 I think I am past that now.

 If I comment out
 $convert=$new_com-DMStoTIFFconv('C:\\TEST\\04186177.dms','C:\\TEST\04186177.tif');
 the Hello Happy World text prints to the screen no problem.

 But when I try to access the VB to call the actual DTM_CONVDMSToMultiTIFF
 function I am getting one of two errors. I am either timing out, or getting
 a message saying incomplete headers.

 The D32_CONV.DLL file is a conversion library that will convert a file from
 DMS format to TIF based on two parameters. Since this function is converting
 a document, do you think my problem is trying to assign that to the $convert
 variable instead of a file output location?


I wouldn't think it should matter much, but I notice you've got your
VB function declared to return a String, and never give it a value.
Shouldn't it just return the Integer value that the internal function
call is returning?

' VB Function
Public Function DMStoTIFFconv(ByVal FullPathFrom As String, ByVal FullPathTo
As String) As Integer
   DMStoTIFFconv = DTM_CONVDMSToMultiTIFF(FullPathFrom, FullPathTo)
End Function

Also, I'm wondering whether the double-slashes are getting passed into
the object method rather than being treated as escape characters. You
might try passing one of those values to your Hello() method to make
sure they are going into your class correctly.

This also doesn't begin to delve into whether the COM object uses the
same security context as PHP. I would think so, but that's just a
guess.

Andrew

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Using DLL with PHP

2009-02-10 Thread Dan Shirah
 Alrighty, so I went a different route...

I created my own ActiveX DLL...one that I know I can register.

Starting out really simple:

//My VB code
Public Function hello() As String

hello = Hello World!
End Function

//My PHP code
?php
function Hello() {
$new_com = new COM(DMStoTIFF.conv);
$output=$new_com-hello();
echo $output;}
Hello();
?

So, after I register the DLL on the server my PHP page is correctly
displaying the Hello World! dialog.

What I'm having problems with now is trying to pass a variable to the DLL.

Shouldn't I be able to do this just like any other PHP class/function?


Re: [PHP] Using DLL with PHP

2009-02-10 Thread Andrew Ballard
On Tue, Feb 10, 2009 at 11:59 AM, Dan Shirah mrsqua...@gmail.com wrote:
 Alrighty, so I went a different route...

 I created my own ActiveX DLL...one that I know I can register.

 Starting out really simple:

 //My VB code
 Public Function hello() As String

 hello = Hello World!
 End Function

 //My PHP code
 ?php
 function Hello() {
 $new_com = new COM(DMStoTIFF.conv);
 $output=$new_com-hello();
 echo $output;}
 Hello();
 ?

 So, after I register the DLL on the server my PHP page is correctly
 displaying the Hello World! dialog.

 What I'm having problems with now is trying to pass a variable to the DLL.

 Shouldn't I be able to do this just like any other PHP class/function?

Generally I think you can. You may run into issues where the function
parameters and return values must be defined as variants in your DLL,
or you may need to cast your PHP variables into instances of the
VARIANT class.

In ASP I mostly used the Scripting.Dictionary (like a hash table, I
guess, since arrays in VBScript are all integer-indexed),
Scripting.FileSystemObject, the ADODB library for database access, and
sometimes a utility to manipulate images, process file uploads, or
file compression. PHP already has extensions for all of these, so I
haven't had to delve into the complexity of using COM in PHP.

Just for kicks, I just tried this in Zend Studio which is running PHP
5.2.0 under WinXP, and it worked as expected:

?php

$some_file = '';  // PATH TO SOME FILE

$x = new COM('Scripting.FileSystemObject');

if ($x-FileExists($some_file)) {
echo 'The file exists!';
} else {
echo 'The file does not exist.';
}

?

Andrew

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Using DLL with PHP

2009-02-10 Thread Shawn McKenzie
Dan Shirah wrote:
  Alrighty, so I went a different route...
 
 I created my own ActiveX DLL...one that I know I can register.
 
 Starting out really simple:
 
 //My VB code
 Public Function hello() As String
 
 hello = Hello World!
 End Function
 
 //My PHP code
 ?php
 function Hello() {
 $new_com = new COM(DMStoTIFF.conv);
 $output=$new_com-hello();
 echo $output;}
 Hello();
 ?
 
 So, after I register the DLL on the server my PHP page is correctly
 displaying the Hello World! dialog.
 
 What I'm having problems with now is trying to pass a variable to the DLL.
 
 Shouldn't I be able to do this just like any other PHP class/function?
 
It doesn't appear that your function accepts a parameter.  What does
this do:

//VB
Public Function hello(ByVal name As String) As String
hello = Hello   name  !
End Function

//PHP
echo $new_com-hello(Dan);

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Using DLL with PHP

2009-02-10 Thread Dan Shirah

  It doesn't appear that your function accepts a parameter.  What does
 this do:

 //VB
 Public Function hello(ByVal name As String) As String
hello = Hello   name  !
 End Function

 //PHP
 echo $new_com-hello(Dan);

 --
 Thanks!
 -Shawn
 http://www.spidean.com


Shawn I tried what you suggested but it returns the following:

*Fatal error*: Cannot pass parameter 1 by reference


Re: [PHP] Using DLL with PHP

2009-02-10 Thread Shawn McKenzie
Dan Shirah wrote:
  It doesn't appear that your function accepts a parameter.  What does
 this do:

 //VB
 Public Function hello(ByVal name As String) As String
hello = Hello   name  !
 End Function

 //PHP
 echo $new_com-hello(Dan);

 --
 Thanks!
 -Shawn
 http://www.spidean.com

 
 Shawn I tried what you suggested but it returns the following:
 
 *Fatal error*: Cannot pass parameter 1 by reference
 
Just guessing as I haven't used the PHP COM stuff, but what do you get
if you change ByVal to ByRef?

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Using DLL with PHP

2009-02-10 Thread Dan Shirah

  Just guessing as I haven't used the PHP COM stuff, but what do you get
 if you change ByVal to ByRef?

 --
  Thanks!
 -Shawn
 http://www.spidean.com


Ooops!  My fault!  I created a new dll so I could keep the currently working
one and forgot to register it..

Registered and it allowed the passing of the variable and the display came
out correctly!

Baby Steps...

Now I just need to incorporate a Lib .dll call into my working activex
dll and I might be on my way.


Re: [PHP] Using DLL with PHP

2009-02-09 Thread Dan Shirah

 Check out the com [www.php.net/com] functionality

 Bastien

Alrighty, I'm trying to use the COM function, but not getting much of
anywhere.

This is what I have:

?php
// The VB function for reference
/*function DTM_CONVDMSToMultiTIFF Lib D32_CONV.DLL _
(ByVal FullPathFrom As String, ByVal FullPathTo As String) As Integer*/

//Create a function in PHP to call the DLL
function DMStoTIFF() {
$my_com = new COM('D32_CONV.DLL');
$output = $my_com-DTM_CONVDMSToMultiTIFF(C:\TEST\04186177.dms,
C:\TEST\04186177.tiff);
}
DMStoTIFF();
?

But I am getting the error below:

*Fatal error*: Uncaught exception 'com_exception' with message 'Failed to
create COM object `D32_CONV.DLL': Invalid syntax

Any ideas?


Re: [PHP] Using DLL with PHP

2009-02-09 Thread Andrew Ballard
On Mon, Feb 9, 2009 at 11:10 AM, Dan Shirah mrsqua...@gmail.com wrote:

 Check out the com [www.php.net/com] functionality

 Bastien

 Alrighty, I'm trying to use the COM function, but not getting much of
 anywhere.

 This is what I have:

 ?php
 // The VB function for reference
 /*function DTM_CONVDMSToMultiTIFF Lib D32_CONV.DLL _
 (ByVal FullPathFrom As String, ByVal FullPathTo As String) As Integer*/

 //Create a function in PHP to call the DLL
 function DMStoTIFF() {
 $my_com = new COM('D32_CONV.DLL');
 $output = $my_com-DTM_CONVDMSToMultiTIFF(C:\TEST\04186177.dms,
 C:\TEST\04186177.tiff);
 }
 DMStoTIFF();
 ?

 But I am getting the error below:

 *Fatal error*: Uncaught exception 'com_exception' with message 'Failed to
 create COM object `D32_CONV.DLL': Invalid syntax

 Any ideas?


I can't help much, but this might get you started.

1) Does the DLL you are trying to use actually supports COM. I know some don't.

2) I'm pretty sure that the string you pass to new COM('...') should
be the name the class as registered with Windows, not the actual file
name. They are usually something like 'Scripting.FileSystemObject',
'word.application', 'ADODB.Recordset', etc.



Andrew

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Using DLL with PHP

2009-02-09 Thread Boyd, Todd M.
 -Original Message-
 From: Andrew Ballard [mailto:aball...@gmail.com]
 Sent: Monday, February 09, 2009 10:30 AM
 To: Dan Shirah
 Cc: Phpster; PHP-General list
 Subject: Re: [PHP] Using DLL with PHP
 
 On Mon, Feb 9, 2009 at 11:10 AM, Dan Shirah mrsqua...@gmail.com
 wrote:
 
  Check out the com [www.php.net/com] functionality
 
  Bastien
 
  Alrighty, I'm trying to use the COM function, but not getting much of
  anywhere.
 
  This is what I have:
 
  ?php
  // The VB function for reference
  /*function DTM_CONVDMSToMultiTIFF Lib D32_CONV.DLL _
  (ByVal FullPathFrom As String, ByVal FullPathTo As String) As
 Integer*/
 
  //Create a function in PHP to call the DLL
  function DMStoTIFF() {
  $my_com = new COM('D32_CONV.DLL');
  $output = $my_com-DTM_CONVDMSToMultiTIFF(C:\TEST\04186177.dms,
  C:\TEST\04186177.tiff);
  }
  DMStoTIFF();
  ?
 
  But I am getting the error below:
 
  *Fatal error*: Uncaught exception 'com_exception' with message
 'Failed to
  create COM object `D32_CONV.DLL': Invalid syntax
 
  Any ideas?
 
 
 I can't help much, but this might get you started.
 
 1) Does the DLL you are trying to use actually supports COM. I know
 some don't.
 
 2) I'm pretty sure that the string you pass to new COM('...') should
 be the name the class as registered with Windows, not the actual file
 name. They are usually something like 'Scripting.FileSystemObject',
 'word.application', 'ADODB.Recordset', etc.

I believe you can also call it by its Public Key Token (a GUID), though that 
may be a new convention introduced with the .NET framework that is not 
backwards-compatible with plain COM objects...


// Todd


Re: [PHP] Using DLL with PHP

2009-02-09 Thread Andrew Ballard
On Mon, Feb 9, 2009 at 12:10 PM, Dan Shirah mrsqua...@gmail.com wrote:
 I can't help much, but this might get you started.

 1) Does the DLL you are trying to use actually supports COM. I know some
 don't.

 2) I'm pretty sure that the string you pass to new COM('...') should
 be the name the class as registered with Windows, not the actual file
 name. They are usually something like 'Scripting.FileSystemObject',
 'word.application', 'ADODB.Recordset', etc.



 Andrew

 The DLL I am trying to work with was written by an outside agency.

 Their application uses this dll to convert DMS images (Their proprietary
 format) to TIFF images.

 Naturally they are not very forth coming to share the functionality of their
 software, but I was able to get the VB function that calls the DLL for
 conversion.

 Private Declare Function DTM_CONVDMSToMultiTIFF Lib D32_CONV.DLL _
 (ByVal FullPathFrom As String, ByVal FullPathTo As String) As
 Integer

 So, I was hoping to be able to call that DLL in PHP and pass it the two
 values I specify in my application.

 In order to be used by COM is the DLL required to be placed in the SYSTEM or
 SYSTEM32 folder?

No. When I was doing an ASP (not .NET) site, we registered them from a
custom path just for our web app.

 Or does it have to be a DLL that can be registered?

I believe you do have to register it with regsvr32 for it to be visible.

I think the GUID that Todd mentioned might even work, but I've only
ever used the ProgID. If you don't know the ProgID that is registered,
you should be able to find it in the Windows registry after you've
registed it with regsvr32. If you search for the file name, it should
find an entry somewhere under \HKEY_CLASSES_ROOT\CLSID\(some
GUID)\InprocServer32 that has a value of the full path to your DLL
file. The ProgID is the next key down below InprocServer32, labeled
aptly ProgID.

Andrew

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Using DLL with PHP

2009-02-09 Thread Boyd, Todd M.
 -Original Message-
 From: Andrew Ballard [mailto:aball...@gmail.com]
 Sent: Monday, February 09, 2009 11:21 AM
 To: Dan Shirah
 Cc: Phpster; PHP-General list
 Subject: Re: [PHP] Using DLL with PHP
 
 On Mon, Feb 9, 2009 at 12:10 PM, Dan Shirah mrsqua...@gmail.com
 wrote:
  I can't help much, but this might get you started.
 
  1) Does the DLL you are trying to use actually supports COM. I know
 some
  don't.
 
  2) I'm pretty sure that the string you pass to new COM('...') should
  be the name the class as registered with Windows, not the actual
 file
  name. They are usually something like 'Scripting.FileSystemObject',
  'word.application', 'ADODB.Recordset', etc.
 
 
 
  Andrew
 
  The DLL I am trying to work with was written by an outside agency.
 
  Their application uses this dll to convert DMS images (Their
 proprietary
  format) to TIFF images.
 
  Naturally they are not very forth coming to share the functionality
 of their
  software, but I was able to get the VB function that calls the DLL
 for
  conversion.
 
  Private Declare Function DTM_CONVDMSToMultiTIFF Lib D32_CONV.DLL _
  (ByVal FullPathFrom As String, ByVal FullPathTo As
 String) As
  Integer
 
  So, I was hoping to be able to call that DLL in PHP and pass it the
 two
  values I specify in my application.
 
  In order to be used by COM is the DLL required to be placed in the
 SYSTEM or
  SYSTEM32 folder?
 
 No. When I was doing an ASP (not .NET) site, we registered them from a
 custom path just for our web app.
 
  Or does it have to be a DLL that can be registered?
 
 I believe you do have to register it with regsvr32 for it to be
 visible.
 
 I think the GUID that Todd mentioned might even work, but I've only
 ever used the ProgID. If you don't know the ProgID that is registered,
 you should be able to find it in the Windows registry after you've
 registed it with regsvr32. If you search for the file name, it should
 find an entry somewhere under \HKEY_CLASSES_ROOT\CLSID\(some
 GUID)\InprocServer32 that has a value of the full path to your DLL
 file. The ProgID is the next key down below InprocServer32, labeled
 aptly ProgID.

I believe that the GUID will only be used to look-up class libraries that have 
already been registered (either via regsvr32 or via the Global Assembly Cache 
in c:\Windows\Assembly). I believe your ProgID suggestion will work just fine 
for pre-.NET DLLs, anyway. :)


// Todd


Re: [PHP] Using DLL with PHP

2009-02-09 Thread Dan Shirah

  I can't help much, but this might get you started.

 1) Does the DLL you are trying to use actually supports COM. I know some
 don't.

 2) I'm pretty sure that the string you pass to new COM('...') should
 be the name the class as registered with Windows, not the actual file
 name. They are usually something like 'Scripting.FileSystemObject',
 'word.application', 'ADODB.Recordset', etc.



 Andrew

The DLL I am trying to work with was written by an outside agency.

Their application uses this dll to convert DMS images (Their proprietary
format) to TIFF images.

Naturally they are not very forth coming to share the functionality of their
software, but I was able to get the VB function that calls the DLL for
conversion.

Private Declare Function DTM_CONVDMSToMultiTIFF Lib D32_CONV.DLL _
(ByVal FullPathFrom As String, ByVal FullPathTo As String) As
Integer

So, I was hoping to be able to call that DLL in PHP and pass it the two
values I specify in my application.

In order to be used by COM is the DLL required to be placed in the SYSTEM or
SYSTEM32 folder?

Or does it have to be a DLL that can be registered? Or placed in the SYSTEM
Path?


Re: [PHP] Using DLL with PHP

2009-02-09 Thread Dan Shirah

 I believe you do have to register it with regsvr32 for it to be visible.

 I think the GUID that Todd mentioned might even work, but I've only
 ever used the ProgID. If you don't know the ProgID that is registered,
 you should be able to find it in the Windows registry after you've
 registed it with regsvr32. If you search for the file name, it should
 find an entry somewhere under \HKEY_CLASSES_ROOT\CLSID\(some
 GUID)\InprocServer32 that has a value of the full path to your DLL
 file. The ProgID is the next key down below InprocServer32, labeled
 aptly ProgID.

 Andrew

I might be out of luck.

When I try and run regsvr32 to register the file it says the DLL was
loaded, but the DllRegistryServer entry point was not found. This file
cannot be registered.


Re: [PHP] Using DLL with PHP

2009-02-09 Thread Dan Shirah
 H, maybe it's not a problem with the DLL I'm trying to access because
just doing a simple:
$my_com = new COM(Excel.Application);

Gives me the same error:
*Fatal error*: Uncaught exception 'com_exception' with message 'Failed to
create COM object `Excel.Application': Invalid syntax '

I've checked my PHP.ini and COM is enabled...


Re: [PHP] Using DLL with PHP

2009-02-09 Thread Andrew Ballard
On Mon, Feb 9, 2009 at 3:21 PM, Dan Shirah mrsqua...@gmail.com wrote:
  H, maybe it's not a problem with the DLL I'm trying to access because
 just doing a simple:
 $my_com = new COM(Excel.Application);

 Gives me the same error:
 *Fatal error*: Uncaught exception 'com_exception' with message 'Failed to
 create COM object `Excel.Application': Invalid syntax '

 I've checked my PHP.ini and COM is enabled...


Is Excel installed on the web server? What happens if you try either
'Scripting.Dictionary' or 'Scripting.FileSystemObject'? (I think those
are both be part of VBScript, so they should be available.)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Using DLL with PHP

2009-02-06 Thread Dan Shirah
Howdy,

I'm looking for a little guidance here.

I'm trying to re-write a VB function in PHP.

This is the function I'm working with:


Private Declare Function DTM_CONVDMSToMultiTIFF Lib D32_CONV.DLL _

(ByVal FullPathFrom As String, ByVal FullPathTo As String) As
Integer

 Naturally I would start off with function() from PHP as well and I will
also already have my two variables that I need to pass to the DLL:

$FullPathFrom = this\is\my\path;
$FullPathTo = this\is\my\path;

function DTM_CONVDMSToMultiTIFF ( )

But I am unsure of how I would call and pass the variables to the DLL. I've
looked into W32api, but not sure if that's even what I need.

Any ideas?

Thanks,
Dan


Re: [PHP] Using DLL with PHP

2009-02-06 Thread Phpster

Check out the com [www.php.net/com] functionality

Bastien

Sent from my iPod

On Feb 6, 2009, at 15:58, Dan Shirah mrsqua...@gmail.com wrote:


Howdy,

I'm looking for a little guidance here.

I'm trying to re-write a VB function in PHP.

This is the function I'm working with:


Private Declare Function DTM_CONVDMSToMultiTIFF Lib D32_CONV.DLL _

   (ByVal FullPathFrom As String, ByVal FullPathTo As  
String) As

Integer

Naturally I would start off with function() from PHP as well and I  
will

also already have my two variables that I need to pass to the DLL:

$FullPathFrom = this\is\my\path;
$FullPathTo = this\is\my\path;

function DTM_CONVDMSToMultiTIFF ( )

But I am unsure of how I would call and pass the variables to the  
DLL. I've

looked into W32api, but not sure if that's even what I need.

Any ideas?

Thanks,
Dan


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php