It's a wiki containing:
- API signatures and type definitions
- gotchas, tips and samples
- alternative managed APIs
- other community resources
TWebResponse = class(TObject)
...
public
...
procedure SendResponse; virtual; abstract;
procedure SendRedirect(const URI: string); virtual; abstract;
procedure SendStream(AStream: TStream); virtual; abstract;
...
end;
type
TPartialFileStream = class(TStream)
private
FFileStream: TFileStream;
FSize: Int64;
FStartPos: Int64;
public
constructor Create(const FileName: string; AStartPos, ASize: Int64);
destructor Destroy; override;
function Read(var Buffer; Count: Longint): Longint; override;
function Write(const Buffer; Count: Longint): Longint; override;
function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override;
end;
{ TPartialFileStream public }
constructor TPartialFileStream.Create(const FileName: string; AStartPos, ASize: Int64);
var
FileSize: Int64;
begin
inherited Create;
FFileStream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyNone);
FileSize := FFileStream.Size;
if (ASize < 0) or (ASize > FileSize) or (AStartPos < 0) or (AStartPos > FileSize) or
(FFileStream.Seek(AStartPos, soBeginning) <> AStartPos) then
raise EReadError.CreateRes(@SReadError);
FStartPos := AStartPos;
if ASize = 0 then
FSize := FileSize - FStartPos
else
FSize := ASize;
end;
destructor TPartialFileStream.Destroy;
begin
FFileStream.Free;
inherited Destroy;
end;
function TPartialFileStream.Read(var Buffer; Count: Longint): Longint;
begin
if FFileStream.Position + Count > FStartPos + FSize then
Count := FStartPos + FSize - FFileStream.Position;
if Count > 0 then
Result := FFileStream.Read(Buffer, Count)
else
Result := 0;
end;
function TPartialFileStream.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64;
var
NewPos: Int64;
begin
case Origin of
soBeginning:
Result := FFileStream.Seek(FStartPos + Offset, soBeginning) - FStartPos;
soCurrent:
begin
NewPos := FFileStream.Position + Offset - FStartPos;
if NewPos < 0 then
NewPos := 0;
if NewPos > FSize then
NewPos := FSize;
Result := FFileStream.Seek(FStartPos + NewPos, soBeginning) - FStartPos;
end;
soEnd:
Result := FFileStream.Seek(FStartPos + FSize + Offset, soBeginning) - FStartPos;
else
Result := -1;
end;
end;
function TPartialFileStream.Write(const Buffer; Count: Longint): Longint;
begin
Result := 0; // this stream is read-only
end;
Stream := TPartialFileStream.Create(FileName, StartPos, Len);
Response.StatusCode := HTTP_STATUS_OK;
Response.ContentType := 'application/octet-stream';
Response.ContentStream := Stream;
Response.SendResponse;
IPHostEntry hostInfo = Dns.Resolve(Dns.GetHostName());
if (hostInfo.AddressList.Length > 0)
{
string ipAddress = hostInfo.AddressList[0].ToString();
string url = "https://members.dyndns.org/nic/update" +
"?system=dyndns" +
"&hostname=" + userName + "." + hostName +
"&myip=" + ipAddress +
"&wildcard=OFF" +
"&mx=" +
"&backmx=NO" +
"&offline=NO";
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);
request.Credentials = new NetworkCredential(userName, password);
request.UserAgent = "tondrej dyndns test/1.0 tondrej@plonk.net";
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
Console.WriteLine(response.StatusCode);
}
A quote from MSDN:
"There is no indication of success or failure. Failure is rare. There is no extended error information for this function; do not call GetLastError."
I think this gem should be archived for future generations ;-)
It's an excerpt from documentation of CharLower API function.
select ... from my_proc(my_params, ...)
join my_table on ...
IOTAHighlighter
interface declared in ToolsAPI
unit) to convert source code currently open in the editor (or perhaps just selected lines) into an HTML page with highlighted syntax. The style/color codes could be read from the registry, thus respecting your current IDE settings.IOTAHighlighter
interface but don't expect much from it. It seems to point to some generic implementation which does nothing but fill your buffer with $0E
(SyntaxOff
) codes. Doh ;-)