Hi,
I'm afraid, the code you provided will not solve the problem. Acessing a 
non-existing file or an already opened one will lead to a system errormessage 
telling you, what you have done. To circumvent this default beavour, you have 
to turn it off by using the win32 'SetErrorMode ' function (which returns the 
current value)
for example:
{$I-}
  Try
     LastErrorMode := SetErrorMode(SEM_FailCriticalErrors);
     
     // Do your Open or whatever you want here

  Finally
     SetErrorMode(LastErrorMode);
  End;
{$I+}
End;

Have fun
Bob

>     Hope this sample code of mine help u to check if the file is in use
>     
>     
>     function IsFileInUse(const fName: TFileName): Boolean;
>     var
>       HFileRes: HFILE;
>     begin
>       Result := False;
>       HFileRes := CreateFile(PChar(fName),
>                              GENERIC_READ or GENERIC_WRITE,
>                              0,
>                              nil,
>                              OPEN_EXISTING,
>                              FILE_ATTRIBUTE_NORMAL,
>                              0);
>       Result := (HFileRes = INVALID_HANDLE_VALUE);
>       if not Result then  CloseHandle(HFileRes);
>     end;



-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/delphi-en/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to