champy,
Revisa este código:
Código Delphi
[-]
Procedure GetDrive(FileName : String);
var
Driver: Pchar;
i, Length: Integer;
SearchFile : Boolean;
OldErrorMode: word;
begin
OldErrorMode:= SetErrorMode(SEM_NOOPENFILEERRORBOX);
SearchFile := False;
GetMem(Driver, 100);
Length := GetLogicalDriveStrings(100, Driver);
try
for i := 0 to Length-1 do
begin
if GetDriveType(Pchar(Driver[i] + ':\')) = DRIVE_REMOVABLE then
begin
If FileExists(Driver[i] + ':\' + FileName) then
begin
MessageDlg('Archivo Sincronizado en Medio Removible', mtinformation, [mbok], 0);
SearchFile := True;
break;
end;
end;
end;
finally
SetErrorMode(OldErrorMode);
FreeMem(Driver);
if not Searchfile then
MessageDlg('Archivo No Sincronizado en Medio Removible', mtinformation, [mbok], 0)
end;
end;
Esta variante incluye las recomendaciones de beginner01 con el flag
SEM_NOOPENFILEERRORBOX.
Revisa esta información:
Cita:
SEM_NOOPENFILEERRORBOX:
If this flag is set, the operating system does not display a message box when it fails to find a a file. Instead, the error is returned to the calling process.
|
Espero sea útil
Nelson.