![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|||||||
| Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
![]() |
|
|
Herramientas | Buscar en Tema | Desplegado |
|
#1
|
||||
|
||||
|
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):
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. |
|
#2
|
||||
|
||||
|
Cita:
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;
|
|
#3
|
||||
|
||||
|
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. |
![]() |
|
|
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 |
|