if App.ExeName = "new" then '当前可执行文件为new.exe
从命令行或者用enumprocesses API获得old.exe的进程id
用OpenProcess API根据进程id获得进程句柄
if 句柄不为0 then
用WaitForSingleObject等候old.exe进程结束一段时间(可选)
if WaitForSingleObject 返回timeout then
用TerminateProcess杀掉old.exe进程
end if
end if '至此,old.exe进程应该已经终结,old.exe文件可读写
复制new.exe到old.exe
用CreateProcess API运行old.exe并马上返回,退出
elseif 有新的版本 then '当前可执行文件为old.exe
下载新版本到临时文件new.exe
用GetCurrentProcessID API获得当前进程ID
用CreateProcess API运行命令行"new.exe /o:当前进程ID"并马上返回,退出
else
删除new.exe
end if