Class procedure tvtupgrader. updateself (const filename: tvtstring );
VaR
Lbatchfile: textfile;
Lbatchfilename: tvtstring;
Lprocessinfo: tprocessinformation;
Lstartupinfo: tstartupinfo;
Begin
// Batch file name
Lbatchfilename: = extractfilepath (paramstr (0) + '_ deleteme. bat ';
// Open the file and set the overwrite Mode
Assignfile (lbatchfile, lbatchfilename );
Rewrite (lbatchfile );
// Write the batch content
Writeln (lbatchfile, ': try ');
Writeln (lbatchfile, 'del "'+ paramstr (0) + '"');
Writeln (lbatchfile, 'If exist "'+ paramstr (0) +'" '+ 'Goto try ');
Writeln (lbatchfile, 'Copy "'+ filename +'" "'+ paramstr (0) + '"');
Writeln (lbatchfile, 'del "'+ filename + '"');
Writeln (lbatchfile, 'del % 0 ');
// Close the file
Closefile (lbatchfile );
// create a new process execution batch file
fillchar (lstartupinfo, sizeof (lstartupinfo), $00);
lstartupinfo. dwflags: = startf_useshowwindow;
lstartupinfo. wshowwindow: = sw_hide;
If CreateProcess (nil, pchar (lbatchfilename), nil, nil, false,
idle_priority_class, nil, nil, lstartupinfo, lprocessinfo) then
begin
closehandle (lprocessinfo. hthread);
closehandle (lprocessinfo. hprocess);
end;