Edit report at http://bugs.php.net/bug.php?id=48498&edit=1

 ID:               48498
 User updated by:  will at flourishlib dot com
 Reported by:      will at flourishlib dot com
 Summary:          COM object instantiation throws 'Invalid Syntax'
                   exception
 Status:           Bogus
 Type:             Bug
 Package:          COM related
 Operating System: Windows XP SP3
 PHP Version:      5.2.10RC1

 New Comment:

Thanks for the replies/help on this. Is it possible to improve the error
message 

so it says the COM object is "Not found" instead of "Invalid syntax"?



I understand if this is outside the control of PHP.


Previous Comments:
------------------------------------------------------------------------
[2010-04-12 01:30:05] ka...@php.net

This is indeed because CAPICOM.Utilities.1 isn't installed.



What you need to do is to:

1) Install CAPICOM from:
http://www.microsoft.com/downloads/details.aspx?FamilyId=860EE43A-A843-462F-ABB5-FF88EA5896F6&displaylang=en

2) Register the DLL: regsvr32 capicom.dll (capicom.dll is located in the
installed folder in %ProgramFiles%)

------------------------------------------------------------------------
[2010-04-12 00:01:54] phi...@php.net

Please let us know when Capicom is (or is not) available because I have
a fresh XP 

install here, with a new PHP 5.3.2 install, and am also getting "Failed
to create 

COM object 'CAPICOM.Utilities.1': Invalid syntax"

------------------------------------------------------------------------
[2009-11-03 21:29:36] ksin...@php.net

I was able to use CapiCom.Utilities.1 with PHP 5.2.11. Error is
generated when capicom is not registered and class is not available on
the machine.

------------------------------------------------------------------------
[2009-06-27 00:11:06] paul at mantisforge dot org

This functionality seems to work fine in the 5.3.0 rc builds ( PHP 

5.3.0RC5-dev (cli) (built: Jun 27 2009 00:33:01) (DEBUG)).



The following script appears to work for me against most of the 

capicom.utilities functions: 



<?php 



try {

        $util = new COM('CAPICOM.Utilities.1');

} catch (Exception $e) {

        echo $e->getMessage() . "\n";

        echo 'exception initialising com object... terminating...';

}



$string = 'foo';



$encoded = $util->Base64Encode($string); /* encoded string is \r\n 

terminated */

echo $encoded . ' is base 64 encoded string:' . $util-

>Base64Decode($encoded) . "\n";

echo "\n\n";



$hex = $util->BinaryToHex($string);

echo "BinaryToHex: " . $util->BinaryToHex($string) . "\n";

echo "hextobinary: " . $util->HexToBinary($hex) . "\n";

define( 'CAPICOM_ENCODE_BASE64', 0 );



echo "Random Number: " . $util->GetRandom(10, CAPICOM_ENCODE_BASE64) . 

"\n";



$variant = $util->BinaryStringToByteArray($string);

$i = 0;

foreach( $variant as $v) {

 echo "Byte(" . $i++ . "): " . $v . "\n";

}





Outputing:

ZgBvAG8A

 is base 64 encoded string:foo



BinaryToHex: 66006F006F00

hextobinary: foo

Random Number: PiMSnPtckiHFCQ==



Byte(0): 102

Byte(1): 0

Byte(2): 111

Byte(3): 0

Byte(4): 111

Byte(5): 0



----------------------------------



1) It might be worth trying a newer version of php

2) it might be worth checking that the com object is registered 

correctly by attempting to access it from a vbscript

------------------------------------------------------------------------
[2009-06-08 18:05:57] will at flourishlib dot com

Description:
------------
In previous versions of PHP it was possible to create a COM object for
CAPICOM to generate random data. I'm not sure at what version it broke,
but now trying to instantiate the COM object, an exception is thrown
with the message "Failed to create COM object 'CAPICOM.Utilities.1':
Invalid syntax".



This behavior seem to be present on both 5.2.9-2 and 5.2.10RC1.



I've been unable to figure out what this error really means. The ProgID
I'm specifying is valid according to Microsoft -
http://msdn.microsoft.com/en-us/library/aa388176(VS.85).aspx.



Any sort of direction would be useful in trying to solve this issue.

Reproduce code:
---------------
new COM('CAPICOM.Utilities.1');

Expected result:
----------------
A COM object that can be used.

Actual result:
--------------
An exception with the message:

Failed to create COM object 'CAPICOM.Utilities.1': Invalid syntax


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=48498&edit=1

Reply via email to