Ver Mensaje Individual
  #15  
Antiguo 10-12-2012
Avatar de nlsgarcia
[nlsgarcia] nlsgarcia is offline
Miembro Premium
 
Registrado: feb 2007
Ubicación: Caracas, Venezuela
Posts: 2.206
Reputación: 21
nlsgarcia Tiene un aura espectacularnlsgarcia Tiene un aura espectacular
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.
Responder Con Cita