천객만래 [千客萬來] (It has an interminable succession of visitors)

'ocx 등록'에 해당되는 글 2건

  1. 2011.12.12 [개발/delphi] how to register an OCX
  2. 2011.11.28 [delphi] OCX 등록 및 해제
[delphi] How to register an OCX

http://www.delphifaq.com/faq/delphi_windows_API/f515_0.htm

program RegisterMyOCX;
uses
  OLECtl, Windows, Dialogs;
var
  OCXHand: THandle;
  RegFunc: TDllRegisterServer;   //add  to the uses clause
begin
  OCXHand:= LoadLibrary('c:\windows\system\test.ocx');
  RegFunc:= GetProcAddress(OCXHand, 'DllRegisterServer');  //case sensitive
  if RegFunc <> 0 then 
    RegFunc
  else
    ShowMessage('Error!')
  FreeLibrary(OCXHand);

  // You can the same way unregister the OCX: 
  // replace 'DllRegisterServer' by 'DllUnregisterServer'
end.
Posted by SB패밀리
[delphi] OCX 등록 및 해제

// (COM Server) OCX 등록 및 해제 
// usage:
// RegOCX('C:\Test.ocx');


unit ocxUtils; 

interface 

uses 
  Windows, SysUtils, ComObj; 

procedure RegOCX(const DLLName: string); 
procedure UnRegOCX(const DLLName: string); 

implementation 

procedure RegOCX(const DLLName: string); 
begin 
if FileExists(DLLName) then
RegisterComServer(DLLName); 
end; 

procedure UnRegOCX(const DLLName: string); 
type 
  TRegProc = function: HResult; stdcall; 
const 
  RegProcName = 'DllUnregisterServer'; 
var 
  Handle: THandle; 
  RegProc: TRegProc; 
begin 
  Handle := SafeLoadLibrary(DLLName); 
  if Handle <= HINSTANCE_ERROR then 
    raise Exception.CreateFmt('%s: %s', [SysErrorMessage(GetLastError), DLLName]); 
  try 
    RegProc := GetProcAddress(Handle, RegProcName); 
    if Assigned(RegProc) then OleCheck(RegProc) else RaiseLastOSError; 
  finally 
    FreeLibrary(Handle); 
  end; 
end; 

end.

--------------------------------------------------------------
// DLL 레지스트리에 등록
// DllRegisterServer 함수 : Olectl.h
// 
DllUnregisterServer 함수 참조 
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
  OCXHand: THandle;
begin
  OCXHand:=LoadLibrary('c:\windows\system\test.ocx');
  if (GetProcAddress(OCXHand, 'DllRegisterServer')<>nil) then
    ShowMessage('Error!');
  FreeLibrary(OCXHand);
end;

end.

Posted by SB패밀리