Delphi/CB
•  Greatis •  Security •  AppDatabase •  Utilities •  Visual Basic • .NET •  just4fun
Delphi / C++ Builder
Components, utilities and tips for Delphi and C++ Builder developers
Hot Offer
Save your money!
Featured
Ultimate Pack  hot!
Image Editor  new!
Runtime Fusion
Form Designer
Object Inspector
Print Suite Pro
Commented Image
Delphi Toys
WinDowse
Delphi Bonus
TMS Scripter Studio
Form Designer VB
Form Designer .NET

...get more...
for Delphi.NET, C#, VB.NET
for Delphi VCL, BCB 3-6

News Tips .NET Software VCL Software Partners  

Registration OCX
Before an OCX can be used, it must be registered with the System Registry. Suppose the OCX you want to use is called "test.ocx". To register this OCX use code from example below.
You can the same way unregister the OCX: all you have to do is to replace 'DllRegisterServer' by 'DllUnregisterServer'.
You should add some validation code: "Does the file exist", "Was the call to LoadLibrary successful?", ...
Some explanations:
An OCX is a special form of dll, so you can load it in memory with a call to the LoadLibrary API function. An OCX exports two functions to register and unregister the control. You then use GetProcAddress to obtain the address of these functions. You just have then to call the appropriate function. And that's it! You can explore the Registry (with regedit.exe) to verify that the OCX is registered.

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

For more
Win32 programmer's reference

Download source


Our Partner
DevArchive.com
Recommended
just4fun
Useful Resources
Win32.hlp Online
Unix Manual Pages
MegaDetailed.NET
in3steps.com
Newsletters
Subscribe to our news!    Subscribe to our news!


Greatis Software Greatis | Security | AppDatabase | Utilities | Delphi/CB | Visual Basic | .NET | just4fun

Contacts | Add to Favorites | Recommend to a Friend | Privacy Policy | Copyright © 1998-2008 Greatis Software