2011년 3월 15일 화요일

regsvr32.exe 를 사용하지 않고 ActiveX DLL을 레지스트리에 등록하기

Unit Unit1;

Interface

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

Type
TForm1 = Class(TForm)
btRegistryDll: TButton;
btUnRegistryDll: TButton;
Procedure btRegistryDllClick(Sender: TObject);
Procedure btUnRegistryDllClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
End;

Var
Form1: TForm1;

Implementation

{$R *.DFM}

Procedure TForm1.btRegistryDllClick(Sender: TObject);
Type
TDllRegisterServer = Function: HResult; stdcall;
Var
DllRegisterServer: TDllRegisterServer;
hinstance1: HINST;
Begin
hinstance1 := LoadLibrary('Project2.dll');
DllRegisterServer := GetProcAddress(hinstance1, 'DllRegisterServer');
If Assigned(DllRegisterServer) Then DllRegisterServer;
FreeLibrary(hinstance1);
End;

Procedure TForm1.btUnRegistryDllClick(Sender: TObject);
Type
TDllUnregisterServer = Function: HResult; stdcall;
Var
DllUnregisterServer:TDllUnregisterServer;
hinstance1: HINST;
Begin
hinstance1 := LoadLibrary('Project2.dll');
DllUnregisterServer := GetProcAddress(hinstance1, 'DllUnregisterServer');
If Assigned(DllUnregisterServer) Then DllUnregisterServer;
FreeLibrary(hinstance1);
End;

End.

댓글 없음:

댓글 쓰기