사용자 참여란
사용자 참여란입니다. 기본적으로 제가 운영하는 사이트의 강좌/팁 란이지만, 사용자들이 참여할 게시판이 있질 않아서, 혹시나 하는 마음에 추가합니다.
글 수 15
WinInet을 이용한 서버의 있는 파일의 수정 날짜를 구하는 루틴입니다.
업데이트 유무를 판단할때 유용하게 쓰일수 있습니다.
procedure TForm1.Button1Click(Sender: TObject);
var
hSession : HINTERNET;
hService : HINTERNET;
LastModified : SYSTEMTIME;
FileSize : Longint;
dwSize, Reserved : DWORD;
ft1, ft2 : FILETIME;
t : SYSTEMTIME;
buf : String;
begin
hSession := InternetOpen( 'MyApp', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0 );
if Assigned( hSession ) then
begin
hService := InternetOpenUrl( hSession, PChar(Edit1.Text), nil, 0, 0, 0);
if Assigned( hService ) then
begin
dwSize := sizeof(LastModified);
Reserved := 0;
HttpQueryInfo(hService, HTTP_QUERY_LAST_MODifIED or HTTP_QUERY_FLAG_SYSTEMTIME,
@LastModified, dwSize, Reserved);
dwSize := sizeof(FileSize);
Reserved := 0;
HttpQueryInfo(hService, HTTP_QUERY_CONTENT_LENGTH or HTTP_QUERY_FLAG_NUMBER,
@FileSize, dwSize, Reserved);
SystemTimeToFileTime( LastModified, ft2 );
FileTimeToLocalFileTime( ft2, ft1 );
FileTimeToSystemTime( ft1, t );
buf := Format('날짜:%4d/%02d/%02d %2d:%02d:%02d 파일 사이즈:%d',
[t.wYear, t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond, FileSize]);
Memo1.Lines.Add( buf );
end;
InternetCloseHandle( hService );
end;
InternetCloseHandle( hSession );
end;
업데이트 유무를 판단할때 유용하게 쓰일수 있습니다.
procedure TForm1.Button1Click(Sender: TObject);
var
hSession : HINTERNET;
hService : HINTERNET;
LastModified : SYSTEMTIME;
FileSize : Longint;
dwSize, Reserved : DWORD;
ft1, ft2 : FILETIME;
t : SYSTEMTIME;
buf : String;
begin
hSession := InternetOpen( 'MyApp', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0 );
if Assigned( hSession ) then
begin
hService := InternetOpenUrl( hSession, PChar(Edit1.Text), nil, 0, 0, 0);
if Assigned( hService ) then
begin
dwSize := sizeof(LastModified);
Reserved := 0;
HttpQueryInfo(hService, HTTP_QUERY_LAST_MODifIED or HTTP_QUERY_FLAG_SYSTEMTIME,
@LastModified, dwSize, Reserved);
dwSize := sizeof(FileSize);
Reserved := 0;
HttpQueryInfo(hService, HTTP_QUERY_CONTENT_LENGTH or HTTP_QUERY_FLAG_NUMBER,
@FileSize, dwSize, Reserved);
SystemTimeToFileTime( LastModified, ft2 );
FileTimeToLocalFileTime( ft2, ft1 );
FileTimeToSystemTime( ft1, t );
buf := Format('날짜:%4d/%02d/%02d %2d:%02d:%02d 파일 사이즈:%d',
[t.wYear, t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond, FileSize]);
Memo1.Lines.Add( buf );
end;
InternetCloseHandle( hService );
end;
InternetCloseHandle( hSession );
end;






