Delphi World - это проект, являющийся сборником статей и малодокументированных возможностей  по программированию в среде Delphi. Здесь вы найдёте работы по следующим категориям: delphi, delfi, borland, bds, дельфи, делфи, дэльфи, дэлфи, programming, example, программирование, исходные коды, code, исходники, source, sources, сорцы, сорсы, soft, programs, программы, and, how, delphiworld, базы данных, графика, игры, интернет, сети, компоненты, классы, мультимедиа, ос, железо, программа, интерфейс, рабочий стол, синтаксис, технологии, файловая система...
Запуск программы

Оформил: DeeCo
Автор: http://www.swissdelphicenter.ch

{ Open a file or starts a programm (without parameters) }

 procedure OpenFile(FileName: string);
 var
   c: array[0..800] of Char;
 begin
   StrPCopy(c, FileName);
   ShellExecute(Application.Handle, 'open', c, nil, nil, SW_NORMAL);
 end;

 { Starts a programm with commandline parameters }

 procedure OpenProgram(prog, params: string);
 var
   c, p: array[0..800] of Char;
 begin
   StrPCopy(c, prog);
   StrPCopy(p, params);
   ShellExecute(Application.Handle, 'open', c, p, nil, SW_NORMAL);
 end;

 { Starts a program and wait until its terminated: 
  WindowState is of the SW_xxx constants }

 function ExecAndWait(const FileName, Params: string;
   WindowState: Word): Boolean;
 var
   SUInfo: TStartupInfo;
   ProcInfo: TProcessInformation;
   CmdLine: string;
 begin
   { Enclose filename in quotes to take care of 
    long filenames with spaces. }
   CmdLine := '"' + FileName + '"' + Params;
   FillChar(SUInfo, SizeOf(SUInfo), #0);
   with SUInfo do
   begin
     cb := SizeOf(SUInfo);
     dwFlags := STARTF_USESHOWWINDOW;
     wShowWindow := WindowState;
   end;
   Result := CreateProcess(nil, PChar(CmdLine), nil, nil, False,
     CREATE_NEW_CONSOLE or
     NORMAL_PRIORITY_CLASS, nil,
     PChar(ExtractFilePath(FileName)),
     SUInfo, ProcInfo);
   { Wait for it to finish. }
   if Result then
     WaitForSingleObject(ProcInfo.hProcess, INFINITE);
 end;

 { Execute a complete shell command line and waits until terminated. }

 function ExecCmdLineAndWait(const CmdLine: string;
   WindowState: Word): Boolean;
 var
   SUInfo: TStartupInfo;
   ProcInfo: TProcessInformation;
 begin
   { Enclose filename in quotes to take care of 
    long filenames with spaces. }
   FillChar(SUInfo, SizeOf(SUInfo), #0);
   with SUInfo do
   begin
     cb := SizeOf(SUInfo);
     dwFlags := STARTF_USESHOWWINDOW;
     wShowWindow := WindowState;
   end;
   Result := CreateProcess(nil, PChar(CmdLine), nil, nil, False,
     CREATE_NEW_CONSOLE or
     NORMAL_PRIORITY_CLASS, nil,
     nil {PChar(ExtractFilePath(Filename))},
     SUInfo, ProcInfo);
   { Wait for it to finish. }
   if Result then
     WaitForSingleObject(ProcInfo.hProcess, INFINITE);
 end;

 { Execute a complete shell command line without waiting. }

 function OpenCmdLine(const CmdLine: string;
   WindowState: Word): Boolean;
 var
   SUInfo: TStartupInfo;
   ProcInfo: TProcessInformation;
 begin
   { Enclose filename in quotes to take care of 
    long filenames with spaces. }
   FillChar(SUInfo, SizeOf(SUInfo), #0);
   with SUInfo do
   begin
     cb := SizeOf(SUInfo);
     dwFlags := STARTF_USESHOWWINDOW;
     wShowWindow := WindowState;
   end;
   Result := CreateProcess(nil, PChar(CmdLine), nil, nil, False,
     CREATE_NEW_CONSOLE or
     NORMAL_PRIORITY_CLASS, nil,
     nil {PChar(ExtractFilePath(Filename))},
     SUInfo, ProcInfo);
 end;
Проект Delphi World © Выпуск 2002 - 2004
Автор проекта: ___Nikolay