Ver Mensaje Individual
  #2  
Antiguo 27-05-2011
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola Gimli.

Código Delphi [-]
...
uses Registry;

function GetFileNameFont(const FontName: string): string;
const
  RGFONTS='\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts';
var
  Reg: TRegistry;
  Valor: TStrings;
  i : Integer;
  Esta: Boolean;
begin
  Reg:= TRegistry.Create;
  try
    Reg.RootKey:= HKEY_LOCAL_MACHINE;
    if not Reg.OpenKey(RGFONTS, False) then
      raise Exception.Create('Error leyendo clave de registro')
    else
    begin
      Valor:= TStringList.Create;
      try
        Reg.GetValueNames(Valor);
        Esta:= False;
        i:= 0;
        Result:= '';
        while not Esta and (i < Valor.Count) do
        begin
          Result:= Reg.ReadString(Valor[i]);
          if Copy(Valor[i],1,Length(FontName))=FontName then
            Esta:= True;
          Inc(i);
        end;
        if not Esta then
          Result:= '';     // devuelve cadena vacía si no lo encontró
      finally
        Valor.Free;
      end;
    end;
  finally
    Reg.Free;
  end;
end;

Ejemplo de llamada:
Código Delphi [-]
  ShowMessage(GetFileNameFont('Times New Roman'));

Saludos.
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....

Última edición por ecfisa fecha: 27-05-2011 a las 18:18:23. Razón: corrección de código
Responder Con Cita