求助,插入一行代码后提示多了个分号,删除分号后又无法运行
直接上代码---
program Project1;
uses
Windows,
Messages,
SysUtils,
Tlhelp32,
forms,
Dialogs,
shellapi;
{$R *.res}
function EndProcess(ExeFileName:string):integer;
const
PROCESS_TERMINATE = $0001;
var
ContinueLoop: BOOLean;
FSnapshotHandle: THandle;
FProcessEntry32:TProcessEntry32;
begin
Result := 0;
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
while Integer(ContinueLoop) <> 0 do
begin
if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) =
UpperCase(ExeFileName))) then
Result := Integer(
TerminateProcess(OpenProcess(PROCESS_TERMINATE,
BOOL(0),FProcessEntry32.th32ProcessID),0));
ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
end;
CloseHandle(FSnapshotHandle);
end;
function DeleteDirectory(NowPath: string): Boolean; // 删除整个目录
var
search: TSearchRec;
ret: integer;
key: string;
begin
if NowPath[Length(NowPath)] <> '\' then
NowPath := NowPath + '\';
key := NowPath + '*.*';
ret := findFirst(key, faanyfile, search);
while ret = 0 do
begin
if ((search.Attr and fadirectory) = fadirectory) then
begin
if (search.Name <> '.') and (search.name <> '..') then
DeleteDirectory(NowPath + search.name);
end
else
begin
if ((search.Attr and fadirectory) <> fadirectory) then
begin
deletefile(NowPath + search.name);
end;
end;
ret := FindNext(search);
end;
findClose(search);
//removedir(NowPath); 如果需要删除文件夹则添加
result := True;
end;
begin
if Endprocess('BUBMAIN.exe') <> 0 then
// DeleteDirectory('D:\QQMusicCache\WhirlCache');//(我想加入这行代码,但是加入后无法运行。百度了一对说是没多‘;’删除分号后又不能用,困扰一下午求解)
ShellExecute(0, 'open', PChar('C:\Program Files\ABB Industrial IT\Freelance\exe\BUBMAIN.EXE'), nil, nil, SW_SHOW)
else
showmessage('fail');
end.
----
如果是写成这样就可运行
begin
Endprocess('BUBMAIN.exe');
sleep(3000);
DeleteDirectory('D:\QQMusicCache\WhirlCache');
ShellExecute(0, 'open', PChar('C:\Program Files\ABB Industrial IT\Freelance\exe\BUBMAIN.EXE'), nil, nil, SW_SHOW);
end.
[ 本帖最后由 s912360101 于 2014-5-11 18:27 编辑 ]