One of the pitfalls a Windows program may encounter while running in Linux are the circular directory references: i.e. when directory contains some of the higher level directories containing it, so any recursive search algorithm is doomed to be caught in an infinite loop.

The second danger is "minimize to tray" which seems to be working, but since there is no tray (at least no one supported by wine) there is no way to restore your app from the minimized state.

Wine itself does everything to avoid detection, reporting itself as genuine Windows 95/98/200/XP according to its internal settings and even emulating the known bugs of these specific versions.

So far, this one works

Updated one time

[pascal]unit cl_winedetect;

{$mode delphi}
{$longstrings on}

interface

uses
Windows, Classes, SysUtils;

function RunningInWine: longbool;

implementation
Const WineSig: string = 'Wine placeholder DLL';

var
Performed: boolean = false;
Detected: boolean = false;

function RunningInWine: longbool;
var
buf: string;
S: TFileStream;
i: integer;
sd: string;
begin
if Performed then begin
Result:=Detected;
Exit;
end;
Result:=False;
Try
SetLength(sd, 1000);
FillChar(sd[1], 1000, 0);
GetSystemDirectory(@sd[1], 1000);
sd:=Trim(sd);
S:=TFileStream.Create(sd + '\kernel32.dll', fmOpenRead);
SetLength(buf, 1000);
S.ReadBuffer(buf[1], Length(buf));
S.Free;
For i:=1 to length(buf) - length(WineSig) do
if copy (buf, i, length(WineSig)) = WineSig then begin
Result:=True;
Break;
end;
Except
End;
Detected:=Result;
Performed:=true;
end;
end.[/pascal]