size : 2299 uploaded_on : Mon Nov 9 00:00:00 1998 modified_on : Wed Dec 8 14:03:26 1999 title : Associated Executable org_filename : associated.txt author : Michael Ax authoremail : ax@HREF.COM description : Some functions on associated executable keywords : tested : not tested yet submitted_by : Unofficial Delphi Developers FAQ submitted_by_email : uddf@gnomehome.demon.nl uploaded_by : nobody modified_by : nobody owner : nobody lang : plain file-type : text/plain category : delphi-filehandling __END_OF_HEADER__ Associated Executable Michael Ax <ax@HREF.COM> unit UcShell; { Author: Michael Ax http://www.axsystems.com/ Copyright (c) 1995..1997 Michael Ax. All Rights Reserved. This source code is part of TPack from HREF Tools Corp. Obtain purchasing and additional information by sending an email to software@href.com (any subject, any message)... or visit us on the web at http://www.href.com/software/ } 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, // pointer to string for filename // LPCTSTR lpDirectory, // pointer to string for default directory // LPTSTR lpResult // pointer to buffer for string for executable file on return // ); 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.