Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: forum mutilates the code I try to post

  1. #11

    forum mutilates the code I try to post

    Did you try disabling HTML in your post? I know I had some issues when trying to post code with angle brackets <like this> and it thought it was HTML...
    My site: DelphiTuts.com (coming soon)...

    Download Font Studio 4.21 here.

  2. #12

    forum mutilates the code I try to post

    Disabling HTML seems to work...

    [pascal]unit cl_pms;

    {$ifdef fpc}
    {$mode delphi}
    {$endif}

    interface

    uses
    SysUtils {$ifdef win32}, Windows{$else}, baseunix {$endif};

    function ThisIsAnOnlyInstance: boolean;

    implementation

    {$ifdef win32}

    var
    M: THandle;
    Di: boolean = false;

    function ThisIsAnOnlyInstance: boolean;
    var N: string;
    begin
    Result:=True;
    N:=ChangeFileExt(ExtractFileName(ParamStr(0)),'') + 'SingleInstanceMutex';
    M:=OpenMutex(MUTEX_MODIFY_STATE, False, PChar(N));
    if M = 0 then M:=CreateMutex(nil, True, PChar(N))
    else begin
    if WaitForSingleObject(M, 0) <> WAIT_ABANDONED
    then Result:=False;
    end;
    Di:=Result;
    end;

    {$else}

    var
    Fn: string;
    Di: boolean = false;

    function ThisIsAnOnlyInstance: boolean;
    var
    i: integer;
    t: Text;
    s: stat;
    begin
    Result:=True;
    Fn:= '/tmp/.' + ChangeFileExt(ExtractFileName(ParamStr(0)),'') + 'SingleInstanceMutex';
    Try
    if FileExists(Fn) then begin
    i:=0;
    AssignFile(t, Fn);
    Reset(t);
    Readln(t, i);
    CloseFile(t);
    if i = fpGetPid() then Exit
    else
    if DirectoryExists('/proc/' + IntToStr(i)) then begin
    if not FileExists('/proc/' + IntToStr(i) + '/exe') //I'm unsure if
    // any *nix creates one or it's just my distribution
    or ((ExtractFileName(fpReadLink ('/proc/' + IntToStr(i) + '/exe')) = ExtractFileName(ParamStr(0)))
    and not ((Length(ParamStr(0)) >=and(copy(ParamStr(0),1, <> '/tmp/upx')))
    then begin
    Exit(False);
    end;
    end;
    end;
    AssignFile(t, Fn);
    Rewrite(t);
    Writeln(t, fpGetPid());
    CloseFile(t);
    Except
    End;
    Di:=Result;
    end;
    {$endif}

    initialization
    finalization
    Try
    {$ifdef win32}
    if Di then ReleaseMutex(M);
    {$else}
    if Di and FileExists(Fn) then DeleteFile(Fn);
    {$endif}
    Except End;
    end. [/pascal]
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  3. #13

    forum mutilates the code I try to post

    Oh. :idea: Thank you!
    I either forgot to disable it from the start, or my profile settings got reset somehow.

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •