Ассоциативное выполнение
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;
begina1:=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. |