Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 9th, 2005, 2:05 PM   #1
daemonreaver
Newbie
 
Join Date: Mar 2005
Posts: 2
Rep Power: 0 daemonreaver is on a distinguished road
Unhappy How Do I: Rewrite a Delphi 6 console app to run as a DLL for IIS5

I am having an extremely hard time with Delphi 6 Personal. I've got the self-registering part down, but (being VBS writer forever) I can't seem to understand why IIS/ASP's CreateObject can't just be replaced with a string-getter to call a DLL that has no object to get some simple information.

Basically, I have a Console EXE that uses inline ASM code to get the CPU clock, CPu vendor, network IP, machine name (via netbios, again, ASM), and uses windows to get some memory status. This EXE outputs tabled HTML that a PHP or ASP (using ASPexe) includes for a full output.

However, I don't want to proliferate the user's folders with EXE's to all of this information which they don't need. I've made a function to return the calls (IE "UpTime" returns the string of uptime in days, hours, minutes) to whatever calls them.

However, the problem is IIS5 barfs saying invalid ProgID. It's just a function that calls for info from Subs.pas and GetStats.pas, each item is it's own function and all work properly. That's why I think it's in how I'm writing the DLL, since this is the first time trying this.

Note: Delphi 6 Personal does *NOT* have any wizards, so what I have, I've found here or elsewhere, and trying to put it together in a working format is a serious pain without docs.


library SystemInfo;

uses
  ComServ,  SysUtils,  Classes,  ActiveX,  ComObj,
  Subs,  GetStats,  winver,  CallLocal;

//Put everything I could think I'd use in Users for now, not sure 
//what a DLL would use outside Windows, Sysutils and my units.

exports
  DllGetClassObject,
  DllCanUnloadNow,
  DllRegisterServer,
  DllUnregisterServer,
  SysCall;
{$R *.res}

begin
//Not sure if anything goes here, since the Function I want to 
//use is in the Exports list...
end.

unit CallLocal;

interface

uses
  SysUtils,  Windows,  Subs,  GetStats,  winver;
//Note this was written and works as a consol program

function SysCall(itemname: string) :  string; export;

implementation

function SysCall(itemname: string) :  string;

var
  temp: string;

begin
  if itemname = 'UpTime' then temp := UpTime;
  if itemname = 'OSType' then temp := GetWindowsTypeEx.Product;
  if itemname = 'OSKind' then temp := GetWindowsTypeEx.Kind.AsString;
  if itemname = 'OSPack' then temp := GetWindowsTypeEx.ServicePack;
  if itemname = 'OSVer' then temp := GetWindowsTypeEx.OSVersion.AsString;
  if itemname = 'OSSVer' then temp := GetWindowsTypeEx.ServicePackVersion.AsString;
  if itemname = 'NetMachineIP' then temp := LocalIP;
  if itemname = 'NetMachineName' then temp := GetComputerName;
  if itemname = 'NetUserName' then temp := GetUserName;
  if itemname = 'HWProcBench' then temp := Format('%f MHz', [CPU_Speed]);
  if itemname = 'HWProcVendor' then temp := Cpu_Vendor;
  SysCall := temp;
end;
end.
Note that it all works as a console app, but it outputs *all* the data to the PHP/ASP page that uses ASPexec or php's passtrhu(). What I'm trying to do is make it sectional so I can use the UpTime reply on one page, and say F: drive's freespace on another page.

I'm not sure at all how to do this, but I hope I can get some help on this, since this is a completely new field for me, having been writing everything self-contained, P-I, and independant of runtimes.

Writing for a webserver isn't that easy.

Basically, I'd like to see some working self-registering DLL code with a single function that returns text strings to an ASP page that uses:

<%
  'ASP to try to call the DLLs "SysCall" function with 
  'parameter "itemname" as "UpTime" to get the uptime string and insert it.
  'I'm pretty sure this would be correct, however ASP/IIS barfs

  Set Executor = Server.CreateObject("SystemInfo.SysCall")
  Response.Write Executor.itemname("UpTime")
%>
Itemname is the parameter in the Delphi Function, and SysCall is the function's name. I'm not understanding why it fails to execute this call, but like I said, it's completely different to me.

What I am lacking in is a fully working IIS-usable demo to see how to do this, since Delphi lacks any documentation on this usage.

Is there an easier way to write non-object-needing DLL's to just reply a string/integer for a given request? That's basically all I need, not a pile of objects to eat up server memory.

Last edited by daemonreaver; Mar 9th, 2005 at 2:13 PM.
daemonreaver is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:52 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC