Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ASP components.

Posted on 1997-12-10
3
Medium Priority
?
212 Views
Last Modified: 2010-04-04
Hi,

I need help creating an ASP ( Active Server Page ) component in Delphi 3.0, specficlly I need help creating the shell of the program.
0
Comment
Question by:latenight
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Accepted Solution

by:
mshaer earned 1200 total points
ID: 1353349
OK,

This is actually much easier than one might think.

What you have to create to make ASP truly happy is an OCX file.
(This is a DLL that is also a OLE Automation Server). The reason that you want to make it a DLL is that the default setting is
not to allow out of process Automation Servers for ASP.

So if this is the goal, how do you actually do it.

Step 1) Create an OCX project
File : New : ActiveX  : ActiveX Library

this creates a file that looks like this (without the comments) :

library Project1;

uses
  ComServ;   // OLE Automation  Unit

exports
  DllGetClassObject,
  DllCanUnloadNow,
  DllRegisterServer,     // this is called to register the server                          // on the machine (need later)
  DllUnregisterServer;   // this is called to un register the                             // server on the machine (need later)

{$R *.RES}

begin
end.

Step 2) Make the automation stuff
File : New : ActiveX : Automation Object
Automation Object wizard pops up.
Enter the class name  (whatever you want it to be)
DLL's must be Multiple instance
Type library Editer pops up

Step 3) The type library
A type library will be generated with a project an Interface and a CoClass.

Add the methods, properties and enumerations that you require to the Interface. Modify the declarations under the attributes so that they are as required.

REMEMBER : WideString not string

Press refresh when finished.

Step 4) Fill in the code.

In the unit fill in the code in the methods generated. And bobs your uncle.

Step 5) Compile

OK, you have a DLL, now what to do with it

Step 5) Installation on another machine

Remember those two functions,
  DllRegisterServer and
  DllUnregisterServer
That I said would be need later, well now they are needed.

after putting the DLL on the new machine run a program that looks something like this (new form edit box and two buttons)

(notice the uses clause OLECtl)

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, OLECtl;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Label1: TLabel;
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
  OCXHand : THandle;
  RegFunc : TDllRegisterServer;
begin
  OCXHand := LoadLibrary(Pchar(edit1.text));
  RegFunc := GetProcAddress(OCXHand, 'DllRegisterServer');
  RegFunc;
  if RegFunc <> 0 then ShowMessage('error');
  FreeLibrary(OCXHand);
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  OCXHand : THandle;
  RegFunc : TDllRegisterServer;
begin
  OCXHand := LoadLibrary(Pchar(edit1.text));
  RegFunc := GetProcAddress(OCXHand, 'DllUnregisterServer');
  RegFunc;
  if RegFunc <> 0 then ShowMessage('error');
  FreeLibrary(OCXHand);
end;

end.

This is a program which registers or unregisters active X servers

OK, thats it try it out.

Any problems, just ask
0
 

Author Comment

by:latenight
ID: 1353350
Thanks for the great example, can you show me how to access the Response and Request objects of the scripting context?

Thanks.
0
 

Expert Comment

by:mshaer
ID: 1353351
I am not sure that I understand,
do you mean, how do you access the Request and Response objects
from your delphi DLL ?

If so ...

There is a basic problem, these objects are internal ASP objects
with no advertisement of how they work underneath. In fact they
may not be passable at all.

ASP deals with these objects as it wants.

At any rate, the easiest way to duplicate the effect is to write
a bunch of procedures in the DLL which allow the data to be passed.

This is a relatively ugly solution, but it works fine.

ie

Have a couple of procedures

procedure clearValues
procedure AddPair(area, name, value)

and then in an ASP loop
<%YourObject.clearValues%>
<%For Each Item in Request.ServerVariables %>
 <%YourObject.AddPair('ServerVariables', Item, Request.ServerVariables(Item)%>
<%Next%>

If this makes your blood run cold then say and if I have time
I will try and work it out.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

636 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