Delphi ISAPI and Windows 2003 compatiblity
I had a perfetly OK ISAPI on my Windows 2000 Server. Spending months to
write and debug it has made it a smoothly working peace of work. Then
suddenly we decided to test it on a Windows 2003 Server. As you'd
expect, when Microsoft changes a piece of its operating system, it
shouldn't surprise you if you end up recompiling your Delphi projects.
For the start, I tryied just to copy the ISAPI to the new machine and
see if it works. It didn't. It couldn't find the damn thing and was
giving me 404 Page Not Found error and many other stupid errors. So here
is how I solved it:
First of all, you need to "introduce" your code (ISAPI or CGI) to the
new IIS 6. In order to do this, go to IIS MMC and "allow" your DLL (or
CGI exe) in Web Service Management branch of the left panel tree.
Now try to run your ISAPI. It might work depending on the instructions
you have used in your code. If it gives you something like
Server Error 500
Exception: EAccessViolation
Message: Access violation at address 77F4831D in module 'ntdll.dll'.
Write of address 0040476D
Then you need to fix a bug in Delphi kernel. Open SysUtils.pas
(delphi/Source/Rtl/Sys) and replace the GetEnvironmentVariable function
with the following:
function GetEnvironmentVariable(const Name: string): string;
var
Len: integer;
W : String;
begin
Result := '';
SetLength(W,1);
Len := GetEnvironmentVariable(PChar(Name), PChar(W), 1);
if Len > 0 then
begin
SetLength(Result, Len - 1);
GetEnvironmentVariable(PChar(Name), PChar(Result), Len);
end;
end;
Recompile your ISAPI and it should work now. Remember to make sure this
new SysUtil.pas file gets compiled. You might need to delete its DCU
file from Bin or other folders or add its folder to Delphi search path
in order to force delphi to compile it again.
I have found this solution somewhere in a newsgroup, but I can't find it
again to give "JP" his/her credit