Click to See Complete Forum and Search --> : calling a windows .dll


Anon
07-16-2001, 04:44 PM
Help! I'm an experienced VBScript / ASP coder, looking to broaden my horizons and learn php ;-) I've been looking around trying to find an answer to this question: how do you call a windows .dll from php?

I have a large library of components I've written / found in VB, that I normally use in asp pages like so:

set objInfo = Server.Createobject("Getinfo.user")

Username = objInfo.UserName
blah blah blah

does php have an equivalent? is there any way to directly make windows API calls?

any and all hints, links, etc gratefully accepted :)

Anon
07-16-2001, 07:47 PM
Yes. On a win32 machine you can do what you are asking. Here is some sample code I got from somewhere using ADO. Also, check in the article area of this site. I believe there is an article there on it.


<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>

<P>&nbsp;</P>
<?

# example use of ADODB and SQLOLEDB (MS-SQL 7) in PHP 4
# Tested on Win2K with PHP 4.02

$conn_obj = new COM("ADODB.Connection") or die("Cannot start ADO");

// replace myserver with your server name

define ("OLEDB_CONNECTION_STRING", "Provider=SQLOLEDB; Data Source=DB; Initial Catalog=DBNAME; User ID=LOGIN; Password=PASSWORD");

// use SQL Server 7.0 OLE DB Provider

$conn_obj->Open(OLEDB_CONNECTION_STRING);

$command = "select * from tbl"; // SQL Statement

$rs = $conn_obj->Execute($command); // Recordset
$i = 0;

$fld0 = $rs->Fields(0);

while (!$rs->EOF) {
$i += 1;
print "$fld0->value <BR>";
$rs->MoveNext();
}

$rs->Close();




?>


</BODY>

Anon
07-18-2001, 04:43 AM
Take a look at http://www.php.net/manual/en/ref.com.php

I hope that helps,
regards,
Chris