F
FlyDayDream
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure KillProcess(dwProcessId: DWORD);
var
ProcHandle: THandle;
begin
ProcHandle := OpenProcess(1, FALSE, dwProcessID);
try
if ProcHandle <> 0 then
begin
if TerminateProcess(ProcHandle, $FFFFFFFF) then
WaitForSingleObject(ProcHandle, INFINITE);
end;
finally
CloseHandle(ProcHandle);
end;
end;
procedure TForm1.btn1Click(Sender: TObject);
var
ww:Hwnd;
begin
//ww:=FindWindow('TfmMain_LC',nil);
ww:=FindWindow(nil,'天天理财');
if ww<>0 then
begin
////applicaiton.MessageBox(handle,PChar('关闭目前已经运行的程序'),PChar('提示'),IDOK);
//showmessage('关闭目前已经运行的程序');
////PostMessage(ww,WM_CLOSE,0,0);
//Exit;
KillProcess(ww);
end;
try
timer1.Enabled:=true;
nmhttp1.InputFileMode:=true;
nmhttp1.Body:=bbh;
nmhttp1.Get(url);
except
on E: exception do
begin
ShowMessage('请关闭天天理财之后再进行升级!'+#13+e.message);
Exit;
end;
end;
if not fileexists(bbh) then
begin
ShowMessage('下载文件失败,请重新下载!');
Exit;
end;
if shellexecute(handle,nil,pchar(bbh),nil,nil,sw_shownormal)<=32 then
begin
ShowMessage('运行文件失败!');
end else
begin
Application.ProcessMessages;
self.Close;
end;
end;
var
ProcHandle: THandle;
begin
ProcHandle := OpenProcess(1, FALSE, dwProcessID);
try
if ProcHandle <> 0 then
begin
if TerminateProcess(ProcHandle, $FFFFFFFF) then
WaitForSingleObject(ProcHandle, INFINITE);
end;
finally
CloseHandle(ProcHandle);
end;
end;
procedure TForm1.btn1Click(Sender: TObject);
var
ww:Hwnd;
begin
//ww:=FindWindow('TfmMain_LC',nil);
ww:=FindWindow(nil,'天天理财');
if ww<>0 then
begin
////applicaiton.MessageBox(handle,PChar('关闭目前已经运行的程序'),PChar('提示'),IDOK);
//showmessage('关闭目前已经运行的程序');
////PostMessage(ww,WM_CLOSE,0,0);
//Exit;
KillProcess(ww);
end;
try
timer1.Enabled:=true;
nmhttp1.InputFileMode:=true;
nmhttp1.Body:=bbh;
nmhttp1.Get(url);
except
on E: exception do
begin
ShowMessage('请关闭天天理财之后再进行升级!'+#13+e.message);
Exit;
end;
end;
if not fileexists(bbh) then
begin
ShowMessage('下载文件失败,请重新下载!');
Exit;
end;
if shellexecute(handle,nil,pchar(bbh),nil,nil,sw_shownormal)<=32 then
begin
ShowMessage('运行文件失败!');
end else
begin
Application.ProcessMessages;
self.Close;
end;
end;