Sand Box

From Free Pascal wiki
Revision as of 14:45, 28 September 2014 by Minesadorada (talk | contribs)
Jump to navigationJump to search

Heading


Append

 Program Test;
 Uses Crt;

 Var I : Integer;

 Begin
   For I := 0 to 12 do
     WriteLn('Test ',I:2);
 End.

--Graeme 11:03, 23 March 2012 (UTC) The DELPHI style doesn't seem to be supported, so we have to use the SOURCE tag instead.

Sayonara

Test O

How to use an internal link: indent first line.

External link

External link: link title
another link: link title


a image

This text should be placed near the picture, does it? zxvzxcv zxvc xcv xzcv zxcv zxvc zxvc zxcv zxcv zxcv zxcv xcv xcv xcv xcv zxcv zxcv zxcv xcv zxcv zxcv aaaaaaaaaaaaa
And this line were is going? and this line?

a text

This is the text

new section test

Table 2

Header 1 Header 2 Header 3 Header 4
Item 1,1 Item 1,2 Item 1,3 Item 1,4
Item 2,1 Item 2,2 Item 2,3 Item 2,4

Bullets

  • One
  • Two
    • Tree

Numbering

  1. First
  2. Second
  3. Third

Nested Numbering

  1. First
    1. first.one
    2. first.two
    3. first.three
  2. Second
    1. second.one
    2. second.two
    3. second.three

Mixed Numbering

  1. First
    • first.one
    • first.two
    • first.three
  2. Second
    • second.one
    • second.two
    • second.three

indenting first line

      Please note that all contributions to Lazarus-ccr are considered to be released under the GNU Free Documentation License (see Lazarus-ccr:Copyrights for details). If you don't want your writing to be edited mercilessly and redistributed at will, then don't submit it here.

You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. DO NOT SUBMIT COPYRIGHTED WORK WITHOUT PERMISSION!

TEST

es:Probando

Another Test: lets go crazy

I want to create a boxed text:

This is in a box, or so I hope.

This is outside the box, no? And this is a reference to my incomplete Structural Analyis book ThisIsMyShura

Weird: this is in the box as well?
  • And a bullet in italics?

non formatted...

Humm

Float Like A Butterfly

New section?

Let's see... ok

grusskarte

if Graphviz was installed, this would draw a pretty graph...

<graphviz> digraph G {

 rankdir=LR; node [fontsize = "8" shape = "rectangle"]; 
 "Node 1" -> "Node 2";

} </graphviz>

This is a test to see, if I can edit a page after the Bad-Behavior update. fpcfan 22:43, 7 December 2007 (CET)

Tutorial links

30 Second Quick Wiki Tutorial

Use this syntax to include a page within another page: {{:LazAutoUpdater}} Deutsch (de) English (en) español (es) Bahasa Indonesia (id) italiano (it) 日本語 (ja) polski (pl) русский (ru) slovenčina (sk) 中文(中国大陆)‎ (zh_CN)

Test whether an Application is already running

Here's a unit that works under both Windows and Linux

  • There's no need to pass the full application path to the function - the ExeName will usually do. Below code cannot find out its own exename though.
unit uappisrunning;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils
  {$IFDEF WINDOWS}, Windows, JwaTlHelp32{$ENDIF}
  {$IFDEF LINUX},process{$ENDIF};
// JwaTlHelp32 is in fpc\packages\winunits-jedi\src\jwatlhelp32.pas

// Returns TRUE if EXEName is running under Windows or Linux
// Don't pass an .exe extension to Linux!
function AppIsRunning(const ExeName: string):Boolean;

implementation

// These functions return Zero if app is NOT running
// Override them if you have a better implementation

{$IFDEF WINDOWS}
function WindowsAppIsRunning(const ExeName: string): integer;
var
  ContinueLoop: BOOL;
  FSnapshotHandle: THandle;
  FProcessEntry32: TProcessEntry32;

begin
  FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
  ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
  Result := 0;

  while integer(ContinueLoop) <> 0 do
    begin
    if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
      UpperCase(ExeName)) or (UpperCase(FProcessEntry32.szExeFile) =
      UpperCase(ExeName))) then
      begin
      Inc(Result);
      // SendMessage(Exit-Message) possible?
      end;
    ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
    end;

  CloseHandle(FSnapshotHandle);
end;
{$ENDIF}

{$IFDEF LINUX}
function LinuxAppIsRunning(const ExeName: string): integer;
var
  t: TProcess;
  s: TStringList;

begin
  Result := 0;
  t := tprocess.Create(nil);
  t.CommandLine := 'ps -C ' + ExeName;
  t.Options := [poUsePipes, poWaitonexit];

    try
    t.Execute;
    s := TStringList.Create;
      try
      s.LoadFromStream(t.Output);
      Result := Pos(ExeName, s.Text);
      finally
      s.Free;
      end;
    finally
    t.Free;
    end;

end;
{$ENDIF}

function AppIsRunning(const ExeName: string):Boolean;
begin

{$IFDEF WINDOWS}
  Result:=(WindowsAppIsRunning(ExeName) > 0);
{$ENDIF}

{$IFDEF LINUX}
  Result:=(LinuxAppIsRunning(ExeName) > 0);
{$ENDIF}

end;
end.

See also