Hello all. I have developed an ISAPI filter dll for IIS using Delphi 6. The filter will be running on a server we use for development purposes (my company is a website development firm). Its purpose is to remap URLs to sort of emulate host-header redirection without having to set it up manually on the web server. Basically, if you type in:
http://something.ourdomain.com/the filter will modify the request to be
http://www.ourdomain.com/something/The filter works as expected, but I am curious about a few things that are mostly Delphi specific (and have nothing really to do with filter dlls):
1. What does the global variable isMultiThreaded actually do and do I need to set it to true? I have read that it is required by the memory manager to be set to true in multi-threaded apps, but is it necessary in something like this? Although my code is not multi-threaded, the dll can be called by multiple threads at the same time, so I am not sure if that is the same thing as far as the memory manager goes.
2. My code has to make a few calls involving passing some local variables as pchars... Which is the best way to do this.
var
myBuffer: array [0..MAX_BUFFER] of char;
buffSize: integer;
begin
buffSize := MAX_BUFFER;
GetApiProc(@myBuffer, @buffSize) //procedure expects pchar and pointer to an integer.
//do something with myBuffer
SetApiProc(@myBuffer);
end;
OR
var
myBuffer: string;
buffSize: integer;
begin
buffSize := MAX_BUFFER;
setLength(myBuffer, buffSize);
GetApiProc(pchar(myBuffer)
, @buffSize) //procedure expects pchar and pointer to an integer.
//do something with myBuffer
uniquestring(buffSize);
SetApiProc(pchar(myBuffer)
);
end;
or is there another way that is better... My goal here is for this routine to go as fast as possible, and I need to reduce the number of memory allocations to the bare minimum... So basically my question is are string types slower to allocate than character arrays???
Any other advice on getting this to run as fast as possible would be greatly appreciated.
Heath