Программы   Загрузка Партнерство   О компании Контакты  
 
                    
  Карта Сайта   
   





Ассоциативное выполнение



unit UcShell;

interface

uses
  Classes, SysUtils, Windows, ShellApi, Forms;

{---------------------------------------------------------------}

function WinExecutableName(const AssociatedFile: string): string;

procedure WinShellOpen(const AssociatedFile: string);
procedure WinShellPrint(const AssociatedFile: string);
procedure WinShellExecute(const Operation, AssociatedFile: string);

{---------------------------------------------------------------}

implementation

const
  cStrBufSize = 80;

{---------------------------------------------------------------}

function WinExecutableName(const AssociatedFile: string): string;
//HINSTANCE FindExecutable(
//    LPCTSTR lpFile,      // указатель на строку с именем файла
//    LPCTSTR lpDirectory, // указатель на строку с директорией по умолчанию
//    LPTSTR lpResult      // указатель на буфер для строки, возвращаемой выполняемым файлом
//   );
begin
  SetLength(result, cStrBufSize); //ucshell
  FindExecutable(pchar(AssociatedFile), '', pchar(result));
  SetLength(result, strlen(pchar(result)));
end;

//

procedure WinShellExecute(const Operation, AssociatedFile: string);
var
  a1: string;
begin
  a1 := Operation;
  if a1 = '' then
    a1 := 'open';
  ShellExecute(
    application.handle //hWnd: HWND
    , pchar(a1) //Operation: PChar
    , pchar(AssociatedFile) //FileName: PChar
    , '' //Parameters: PChar
    , '' //Directory: PChar
    , SW_SHOWNORMAL //ShowCmd: Integer
    );
  //  GetLastErrorString(0); //ucdialog
end;

procedure WinShellPrint(const AssociatedFile: string);
begin
  WinShellExecute('print', AssociatedFile);
end;

procedure WinShellOpen(const AssociatedFile: string);
begin
  WinShellExecute('open', AssociatedFile);
end;

{-----------------------------------------------------------------}
end.

           




Программы  |  Загрузка  |  Партнерство  |  О компании  |  Контакты

Copyright © LSD Software 2006 - 2011