Solved

PHP and COM

Posted on 2003-11-11
10
201 Views
Last Modified: 2010-04-05
Dear Experts,

I'm trying to develop the COM library with Delphi 7, but I have problems using it in PHP. So far, I have added two COM objects "Domains" (collection) and "Domain". When I launch the simple PHP script below, the exception occurs, and window popups, asking to send the error report to Microsoft.

$domains = new COM("MyLib.Domains");
$domain = $domains->Item(1);
echo $domain->Name;

The ASP analog below, in VBScript works perfect

set Domains = Server.CreateObject("MyLib.Domains")
set Domain = Domains(1)
Response.Write Domain.Name

One interesting thing: when in Delphi I rename property "Domain.Name" to "Domain.DomainName" suddently it starts to work in PHP, but when I start to add other new properties and methods - they fall again.
I have tested it with PHP4.2.1, PHP4.3.2 and PHP5.0.0beta.

Maybe I should take into consideration some important details when I'm developing COM objects with Delphi, or is this is a PHP bug?

TIA,
dumb
0
Comment
Question by:iam_dumb
  • 5
  • 3
10 Comments
 
LVL 5

Expert Comment

by:arjanh
ID: 9725347
Delphi arrays are 0-based, so probably
$domain = $domains->Item(1);
should become
$domain = $domains->Item(0);
0
 
LVL 5

Expert Comment

by:arjanh
ID: 9725361
> Delphi arrays are 0-based, so probably

make that PHP arrays...
0
 

Author Comment

by:iam_dumb
ID: 9725562
Nop, didn't help :(
0
 
LVL 5

Expert Comment

by:arjanh
ID: 9725660
what is the error message that you get?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 5

Expert Comment

by:arjanh
ID: 9725682
And which line exactly is causing the exception? Try commenting out the second and third, then only the third...
0
 

Author Comment

by:iam_dumb
ID: 9725753
There are no exact error message (I'm on XP), there is only common error popup, that ask to send error report to Microsoft if something is wrong.

The exact line, that causes an error is

echo $domain->Name;

Moreover, if for this property in Delphi I add Debug procedure (Debug is a custom procedure, that just writes the string param to my debug file) like shown below, it never invoke the Debug, so I guess, PHP can't find this property for some reason.

function TDomain.Get_Name: WideString;
begin
    Debug('Property Works!');
    Result := FDomain.DomainName;
end;
0
 
LVL 5

Expert Comment

by:arjanh
ID: 9725975
What is the value of
$domains->Item->Count();

And what about
$domain = $domains->Item[0];
or
$domain = $domains->Domain[0];
0
 

Author Comment

by:iam_dumb
ID: 9726209
echo $domains->Item->Count()
raises an exception

echo $domains->Item->Count
raises an exception

echo $domains->Count
returns the valid number of domains

$domain = $domains->Item[0];
raises an exception

$domain = $domains->Item[0];
raises an exception

$domain = $domains->Domain[0];
raises an exception

$domain = $domains->Item(1);
works
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12808394
PAQed with points refunded (250)

modulo
Community Support Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now