Jump to content


Photo

[TRUCO DELPHI] Registrar y Desinstalar un ActiveX en Delphi.


  • Please log in to reply
2 replies to this topic

#1 Rantor777

Rantor777

    Newbie

  • Miembros
  • Pip
  • 7 posts

Posted 05 November 2016 - 02:22 PM

[TRUCO DELPHI] Registrar y Desinstalar un ActiveX en Delphi.

 

Declaración de Tipos.


delphi
  1. type
  2. TDllRegisterServer = function: HResult; stdcall;

Función para registrar. [MÉTODO 1]


delphi
  1. function RegisterOCX(FileName: string): Boolean;
  2. var
  3. OCXHand: THandle;
  4. RegFunc: TDllRegisterServer;
  5. begin
  6. OCXHand := LoadLibrary(PChar(FileName));
  7. RegFunc := GetProcAddress(OCXHand, 'DllRegisterServer');
  8. if @RegFunc <> nil then
  9. Result := RegFunc = S_OK
  10. else
  11. Result := False;
  12. FreeLibrary(OCXHand);
  13. end;

Des Instalar o No Registrar.


delphi
  1. function UnRegisterOCX(FileName: string): Boolean;
  2. var
  3. OCXHand: THandle;
  4. RegFunc: TDllRegisterServer;
  5. begin
  6. OCXHand := LoadLibrary(PChar(FileName));
  7. RegFunc := GetProcAddress(OCXHand, 'DllUnregisterServer');
  8. if @RegFunc <> nil then
  9. Result := RegFunc = S_OK
  10. else
  11. Result := False;
  12. FreeLibrary(OCXHand);
  13. end;

Registrar [MÉTODO 2]


delphi
  1. function RegisterServer(const aDllFileName: string; aRegister: Boolean): Boolean;
  2. type
  3. TRegProc = function: HResult;
  4. stdcall;
  5. const
  6. cRegFuncNameArr: array [Boolean] of PChar =
  7. ('DllUnregisterServer', 'DllRegisterServer');
  8. var
  9. vLibHandle: THandle;
  10. vRegProc: TRegProc;
  11. begin
  12. Result := False;
  13. vLibHandle := LoadLibrary(PChar(aDllFileName));
  14. if vLibHandle = 0 then Exit;
  15. @vRegProc := GetProcAddress(vLibHandle, cRegFuncNameArr[aRegister]);
  16. if @vRegProc <> nil then
  17. Result := vRegProc = S_OK;
  18. FreeLibrary(vLibHandle);
  19. end;

Saludos! @Sir.Dev.A.Lot "Ya he comenzado."


  • 5

#2 poliburro

poliburro

    Advanced Member

  • Administrador
  • 4945 posts
  • LocationMéxico

Posted 05 November 2016 - 04:10 PM

Gracias por el aporte compañero.


  • 0

#3 sir.dev.a.lot

sir.dev.a.lot

    Advanced Member

  • Miembros
  • PipPipPip
  • 545 posts
  • Location127.0.0.1

Posted 07 November 2016 - 01:54 PM

@Rantor777

 

Debes de Seguir, si tu posteas 1 yo posteare 10. (h)


  • 1




IP.Board spam blocked by CleanTalk.