whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

40 Visitors Online


 
...register or unregister a OCX/ActiveX?
Autor: Elias Zurschmiede
Homepage: http://www.delight.ch
[ Print tip ]  

Tip Rating (13):  
     


{1.}

type
  
TDllRegisterServer = function: HResult; stdcall;

function RegisterOCX(FileName: string): Boolean;
var
  
OCXHand: THandle;
  RegFunc: TDllRegisterServer;
begin
  
OCXHand := LoadLibrary(PChar(FileName));
  RegFunc := GetProcAddress(OCXHand, 'DllRegisterServer');
  if @RegFunc <> nil then
    
Result := RegFunc = S_OK
  else
    
Result := False;
  FreeLibrary(OCXHand);
end;

function UnRegisterOCX(FileName: string): Boolean;
var
  
OCXHand: THandle;
  RegFunc: TDllRegisterServer;
begin
  
OCXHand := LoadLibrary(PChar(FileName));
  RegFunc := GetProcAddress(OCXHand, 'DllUnregisterServer');
  if @RegFunc <> nil then
    
Result := RegFunc = S_OK
  else
    
Result := False;
  FreeLibrary(OCXHand);
end;

{**********}

{2.}

function RegisterServer(const aDllFileName: string; aRegister: Boolean): Boolean;
type
  
TRegProc = function: HResult;
  stdcall;
const
  
cRegFuncNameArr: array [Boolean] of PChar =
    ('DllUnregisterServer', 'DllRegisterServer');
var
  
vLibHandle: THandle;
  vRegProc: TRegProc;
begin
  
Result := False;
  vLibHandle := LoadLibrary(PChar(aDllFileName));
  if vLibHandle = 0 then Exit;
    @vRegProc := GetProcAddress(vLibHandle, cRegFuncNameArr[aRegister]);
  if @vRegProc <> nil then
    
Result := vRegProc = S_OK;
  FreeLibrary(vLibHandle);
end;

 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners