Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Proyecto SIF/Veri*Factu/Ley Antifraude > SDK Componente Verifactu para Delphi 7+ - Subforo Errores
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 15-10-2025
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 19.435
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Detectar autofirma instalado (registro)

Estoy revisando el proyecto (hasta ahora no lo había hecho por falta de tiempo y porque tampoco lo necesitaba) y me he encontrado con lo siguiente.
(Perdonad si ya lo habéis hablado)

Resulta que ejecuto la aplicación y siempre me devuelve que Autofirma no está instalado, aunque realmente si está en mi máquina.
Por lo que he visto (o eso me parece) es porque la clave a la que intenta acceder requiere permisos de administrador (al menos en mi caso):

Código Delphi [-]
RootKey := HKEY_CLASSES_ROOT;
if OpenKey('\afirma\shell\open\command',false) then

De forma, que si no ejecuto como administrador, siempre me devuelve vacía y no lo detecta.
Como sugerencia propondría que eso se pueda cargar desde el fichero de configuración, para no obligar a ejecutar como Administrador.
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita
  #2  
Antiguo 16-10-2025
Avatar de seccion_31
seccion_31 seccion_31 is offline
Miembro
 
Registrado: ene 2017
Posts: 472
Poder: 10
seccion_31 Va por buen camino
Cita:
Empezado por Neftali [Germán.Estévez] Ver Mensaje
Estoy revisando el proyecto (hasta ahora no lo había hecho por falta de tiempo y porque tampoco lo necesitaba) y me he encontrado con lo siguiente.
(Perdonad si ya lo habéis hablado)

Resulta que ejecuto la aplicación y siempre me devuelve que Autofirma no está instalado, aunque realmente si está en mi máquina.
Por lo que he visto (o eso me parece) es porque la clave a la que intenta acceder requiere permisos de administrador (al menos en mi caso):

Código Delphi [-]
RootKey := HKEY_CLASSES_ROOT;
if OpenKey('\afirma\shell\open\command',false) then

De forma, que si no ejecuto como administrador, siempre me devuelve vacía y no lo detecta.
Como sugerencia propondría que eso se pueda cargar desde el fichero de configuración, para no obligar a ejecutar como Administrador.
En la 5.7 esto ira cambiado:

Sustituye en uTVerifactu.pas la funcion: function autoFirmaPath:string;

Por estas dos.

Y nos comentas que tal.

Saludos !


Código:
procedure GetProgramFilesPathsFromRegistry(out Path32, Path64: string);
const
  KEY_WOW64_64KEY = $0100;
  KEY_READ = $20019;
var
  _hKey: HKEY;
  Data: array[0..MAX_PATH] of Char;
  DataSize: DWORD;
  RegType: DWORD;
begin
  Path32 := '';
  Path64 := '';

  // 1. Leer la vista de 64 bits del registro (ProgramFilesDir y ProgramFilesDir (x86))
  if RegOpenKeyEx(HKEY_LOCAL_MACHINE,
                  'SOFTWARE\Microsoft\Windows\CurrentVersion',
                  0,
                  KEY_READ or KEY_WOW64_64KEY,
                  _hKey) = ERROR_SUCCESS then
  begin
    // Obtener ProgramFilesDir (64 bits)
    DataSize := SizeOf(Data);
    RegType := REG_SZ;
    if RegQueryValueEx(_hKey, 'ProgramFilesDir', nil, @RegType, @Data, @DataSize) = ERROR_SUCCESS then
      Path64 := Data;

    // Obtener ProgramFilesDir (x86) ? ruta de 32 bits
    DataSize := SizeOf(Data);
    if RegQueryValueEx(_hKey, 'ProgramFilesDir (x86)', nil, @RegType, @Data, @DataSize) = ERROR_SUCCESS then
      Path32 := Data;

    RegCloseKey(_hKey);
  end;

  // 2. Si estamos en Windows de 32 bits, solo existe ProgramFilesDir
  if (Path32 = '') and (Path64 = '') then
  begin
    if RegOpenKeyEx(HKEY_LOCAL_MACHINE,
                    'SOFTWARE\Microsoft\Windows\CurrentVersion',
                    0,
                    KEY_READ,
                    _hKey) = ERROR_SUCCESS then
    begin
      DataSize := SizeOf(Data);
      RegType := REG_SZ;
      if RegQueryValueEx(_hKey, 'ProgramFilesDir', nil, @RegType, @Data, @DataSize) = ERROR_SUCCESS then
        Path32 := Data;  // En 32 bits, esta es la única ruta

      RegCloseKey(_hKey);
    end;
  end;

end;

function autoFirmaPath:string;
var
  Reg: TRegistry;
  i: integer;
  PosiblesRutas: array[0..1] of string;
  ruta32, ruta64:string;
begin

  result:='';
  try
    Reg := TRegistry.Create;
    with Reg do
    begin
      RootKey := HKEY_CLASSES_ROOT;
      if OpenKey('\afirma\shell\open\command',false) then
      begin
        if ValueExists('') then
          Result := Readstring('')
        else
          result:='';
      end
      else
        result:='';

      CloseKey;
    end;

  except
    result:='';
    
  end;

  if result<>'' then exit;

  GetProgramFilesPathsFromRegistry(ruta32, ruta64);

  PosiblesRutas[0] := ruta32+'\AutoFirma\AutoFirma\AutoFirma.exe';
  PosiblesRutas[1] := ruta64+'\AutoFirma\AutoFirma\AutoFirma.exe';

  for i := Low(PosiblesRutas) to High(PosiblesRutas) do
  begin
    if FileExists(PosiblesRutas[i]) then
    begin
        Result := extractFilePath(PosiblesRutas[i]);
        Exit;
    end;
  end;
end;
Responder Con Cita
  #3  
Antiguo 16-10-2025
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 19.435
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Gracias.
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Firmar con AutoFirma y fichero PFX PukinG Envío de registros y sus respuestas 47 16-10-2025 08:59:16
Firmar con autofirma, en modo "batch" seccion_31 SDK Componente Verifactu para Delphi 7+ - Subforo Peticiones 0 03-09-2025 18:46:23
Autofirma (alias del certificado) keys Internet 38 26-02-2022 17:12:06
Detectar Escritura en el Registro de Windows FENIXadr Varios 3 19-01-2011 07:20:20
Detectar un registro bloqueado DavidR Firebird e Interbase 2 18-12-2003 19:48:22


La franja horaria es GMT +2. Ahora son las 03:10:09.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi