作成したアプリをいちいちみんなのPCに設定するのが面倒なので、サーバーに置いて、読みに行くソースをメインのEXEファイルに入れたのですが、
DLLとフォルダをコピーしたいんですけど、
ボリュームファイルとかまでついてきているみたいなので、困っています。
できれば、EXEファイルが入っていても排除するソースにしたいのですが。
var
osr,nsr:TSearchRec;
cnt:Integer;
oft,nft:TFileTime;
ost,nst:TSystemTime;
nd,od:TDateTime;
AppPath:String;
FromPath,ToPath : String;
LCID:Windows.LCID;
FileOp:TShFileOpStruct;
FileAttrs: Integer;
begin
AppPath := ExtractFilePath(Application.ExeName);
FileAttrs := FaDirectory + FaReadOnly;
//DLLのコピー
if FindFirst(UpdatePath + '\*.*',FileAttrs,nsr) = 0 then
begin
Repeat
//共有ファイル先のファイルの日付取得
FileTimeToLocalFileTime(nsr.FindData.ftLastWriteTime,nft);
FileTimeToSystemTime(nft,nst);
nd := SystemTimeToDateTime(nst);
//同じファイル名の既存日付取得
FindFirst(AppPath + nsr.Name,FaAnyFile,osr);
FileTimeToLocalFileTime(osr.FindData.ftLastWriteTime,oft);
FileTimeToSystemTime(oft,ost);
od := SystemTimeToDateTime(ost);
//確認
ShowMessage(nsr.Name + ' : '+ DateTimeToStr(od) + ' : ' + DateTimeToStr(nd));
//もし新しかったらコピー
if od < nd then
begin
//ファイル原本コピー
FromPath := UpDatePath + '\' + nsr.Name + #0#0;
ToPath := AppPath + nsr.Name + #0#0;
with FileOp do
begin
Wnd := frmMain.Handle;
wFunc := FO_COPY;
pFrom := PChar(FromPath);
pTo := PChar(ToPath);
fFlags := FOF_NOCONFIRMATION;//上書き問い合わせ無し
end;
SHFileOperation(FileOp);
end;
until FindNext(nsr) <> 0;
FindClose(nsr);
FindClose(osr);
end;
end;
cnt:integer;//ゴミ宣言です。
updatePath//サーバーのパスが入ってます。
FindFirst(UpdatePath + '\*.*',FileAttrs,nsr)
の'\*.*'を'\*.dll'にしたらDLLだけはとれたんですが、
フォルダのみの取り方が分からず、戻しました。
最悪、DLLのみ回すのと、フォルダのみ回して読むのでもかまわないです。
DirectoryExistsでふるいにかければ簡単では?
あるいは、faDirectoryで検索してみると、それらしいソースが拾えるかも。
あ、さんヒントありがとうございました。
いいソースがありました。
if (nsr.Name <> '.') and (nsr.Name <> '..') then
begin
end;
で囲むとうまくいきました。