Monday, September 15, 2008

Delphi 2009 Generics

In order to use TList TStack, you need to add "generics.collections" into the uses list. For example,

uses generics.collections;

Monday, June 2, 2008

How To Pass A Class Into Function/Procedure?

define the class type as follow... assuming that you are going to pass in a generic TFrame.

type TFrameClass=class of TFrame;

procedure TForm1.CreateSomething(FrameClass: TFrameClass; const Caption: String);
var
F: TFrame;
begin
F := FrameClass.Create(Self);
F.Label1.Caption := Caption;
end;

...
...

begin
CreateSomething(TMyFrame, 'Test);
end.

Sunday, February 24, 2008

How To Open MS Access database in CGI?

I have encountered a problem to open MS Access database from Delphi executable CGI. I always end up with the error "Unspecified error". I figured it out that it must be security issue. MS Access will create a temporary file whenever it is opened. The question is where? After surfing the internet, I found that the temporary file would be created in %temp% folder. But under which profile? After some trial and error, my executable CGI worked after I have granted folder "C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp" with full control right to "IUSR".

MS Access ADO Connection String

Use the syntax below to connect to MS Access database without maintaining DNS (ODBC)

ADOConnection.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + MDBFileName;

How to run Executable CGI in IIS7.0 (Vista)

Step 1. Go to Control Panel and click on Programs
Step 2. Choose "Turn Windows Features On or Off"
Step 3. Check World Wide Web Services and CGI

Step 4. Go to Administrative Tools and open up IIS Manager.
Step 5. Add a virtual application folder, name it "CGI" or "CGI-BIN".
Step 6. Point to the Root Item (your PC name) and choose "ISAPI and CGI Restriction".
Step 7. Click Edit Feature Settings and check "Allow unspecified CGI modules".
Step 8. Click the "CGI" or "CGI-BIN" folder and choose "Handler Mappings".
Step 9. Click "Edit Handler Permission", uncheck "Read" and check "Execute".
Step 10. Double click on "cgi-exe" to change the property if necessary. Example, change request path to *.cgi (from *.exe) if your cgi extension is .cgi instead of .exe.