værsgo her er et helt unit til det pjat
unit ExecuteFile;
interface
procedure Start_Program(PGMsti, Filnavn, ParmStr : String);
//[C:\\windows], [Notepad[.exe]], [test.txt]);
implementation
uses ShellAPI, SysUtils, Dialogs, Forms;
procedure Start_Program(PGMsti, Filnavn, ParmStr : String);
procedure ExecuteFile(const FileName, Params, DefaultDir: string; ShowCmd: Integer);
var
zFileName, zParams, zDir: array[0..79] of Char;
begin
ShellExecute(Application.MainForm.Handle, nil,
StrPCopy(zFileName, FileName), StrPCopy(zParams, Params),
StrPCopy(zDir, DefaultDir), ShowCmd);
end;
begin
if ExtractFileExt(FilNavn) = '' then
FilNavn := FilNavn + '.exe';
if FileExists(PGMsti+ '' + FilNavn) then
ExecuteFile(FilNavn+'',ParmStr,PGMsti+ '\\', 0)
else
ShowMessage('File not found.: '+PGMsti+'\\'+filnavn+' '+ParmStr);
end;
end.
mvh
troels