如何利用網芳自動更新程式
發表於 : 2008年 11月 27日, 18:16
先利用 WNetAddConnection2 來進行 trust , 配合fileage 來比對檔案時間, 再以 copyfile 來
進行更新檔案的複製
進行更新檔案的複製
代碼: 選擇全部
var
str : string;
lpNetResource: _NETRESOURCE;
begin
lpNetResource.dwType := RESOURCETYPE_ANY;
lpNetResource.lpLocalName := Nil;
lpNetResource.lpRemoteName := PChar('\主機');
lpNetResource.lpProvider := Nil;
WNetAddConnection2(lpNetResource, PChar('密碼'), PChar('帳號'), 0);
try
GetDir(0, str);
if not FileExists(Str + '檔案') then
CopyFile('\xxxxx檔案', Pchar(Str + '檔案'), False)
else
if FileAge(Str + '檔案') <> FileAge('\xxxxx檔案') then
begin
CopyFile('\xxxxx檔案', Pchar(Str + '檔案'), False);
end;
finally
//WinExec(pchar(str+'MDIAPP.exe'), SW_SHOWDEFAULT);
//ShowMessage(str+'MDIAPP.exe');
//Application.Terminate;
end;