Hello everybody!

It was so quiet here lately     :)





I want to make one of my programs to run from a read-only Flash stick or CD.
The program tries to detect if it is on a read-only media with this 
function:

function  CanWriteFile(Where: string): 
Boolean;                                 { Returns true if it can write 
that file to disk. ATTENTION it will overwrite the file if it already 
exists ! }
VAR myFile: file;
begin
 Result:= False;
 Assign(myFile, Where);
 TRY
  //FileMode:= 2; { Read/Write access }
  {$I-}
  Rewrite(myFile);
  {$I+}
  Result:= (IOResult = 0);
  Close(myFile);
 Except
 end;

 if Result then SysUtils.DeleteFile(Where);
end;

It returns the correct value, but I have a problem; it rise an error. I 
don't want any errors visible on screen.

---------------------------
Tester2.exe - Write Protect Error
---------------------------
The disk cannot be written to because it is write protected. Please 
remove the write protection from the volume  in drive E:
---------------------------
Cancel   Try Again   Continue  
---------------------------


_______________________________________________
Delphi mailing list -> [email protected]
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

Reply via email to