Re: reading a opened file
- From: erewhon@xxxxxxxxxx (J French)
- Date: Wed, 28 Sep 2005 08:30:05 +0000 (UTC)
On Tue, 27 Sep 2005 14:38:08 +0200, "snide" <nospam@work> wrote:
>I finally came up with this function :
>
>
>function IsFileInUse(fName : string) : boolean;
>var
> HFileRes : HFILE;
>begin
> Result := false;
> if not FileExists(fName) then exit;
>
> HFileRes :=CreateFile(pchar(fName),
> GENERIC_READ, // or GENERIC_WRITE // desiredaccess
> 0, // sharemode
> nil, // SecurityAttributes
> OPEN_EXISTING, // CreationDisposition
> FILE_ATTRIBUTE_NORMAL, // FlagsAndAttributes
> 0); // TemplateFile
>
> Result := (HFileRes = INVALID_HANDLE_VALUE) ;
> if not Result then CloseHandle(HFileRes);
>end;
If FileOpen( FileName, fmOpenRead Or fmShareDenyWrite ) <= 0 Then
ShowMessage( SysErrorMessage( GetLastError );
However this may still screw up the other Application if it tries to
write to the file.
.
- References:
- reading a opened file
- From: snide
- Re: reading a opened file
- From: Fufi
- Re: reading a opened file
- From: snide
- Re: reading a opened file
- From: Maarten Wiltink
- Re: reading a opened file
- From: snide
- reading a opened file
- Prev by Date: Re: Delphi and DSP
- Next by Date: IcompleteInterface = interface(IsubInterface1, IsubInterface2, IsubInterface3) not possible ?
- Previous by thread: Re: reading a opened file
- Next by thread: Re: VerificationProgram0.09 for PointOnLineSegmentIn2D =D
- Index(es):
Relevant Pages
|