Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

FreeLibrary in ActiveForm

Posted on 2002-05-14
4
730 Views
Last Modified: 2007-11-27
Hi all,

I've developed a ActiveX control (TActiveForm) in Delphi 5 to be used only in Internet Explorer 5+ (HTML page).

In this OCX I have to dynamically load and unload a DLL, let's say MYDLL.DLL.

Firstly, I tried to place LoadLibrary in TMyFormX.Initialize, but I couldn't guess the right place to call FreeLibrary.

I now have LoadLibrary in TMyFormX.ActiveFormCreate and FreeLibrary goes into TMyFormX.ActiveFormDestroy

Using breakpoints I can see that FormCreate and Initialize are called many, many times, for example, HTML page reload, but I never could trace FormDestroy.

As I'm having some GPF's in I.E. and details tells me IEXPLORE bla bla bla (you know what I mean..) in MYDLL.DLL I'm very suspicious that LoadLibrary & FreeLibrary are not in right place.

The question:

In which events handlers I must place LoadLibrary & FreeLibrary stuff in my ActiveForm control???

Many thanks in advance,
Itamar
0
Comment
Question by:itamar
  • 2
4 Comments
 
LVL 17

Accepted Solution

by:
inthe earned 210 total points
ID: 7010132
i would only use dll's for holding functions/routines that wanted to be kept seperate from main program for upgrading purposes or good housekeeping etc.. try to load and unload the dll when its needed instead of leaving it loaded.
for example if you have a function that uses it then load for the function then free it.
the reasons here are activex's dont get notified of the form destroy events etc..so it would be difficult to say when would be best to free it.
0
 
LVL 4

Author Comment

by:itamar
ID: 7010160
Hi inthe,

bad news for me!

I have some good reasons to call external DLL's.
The load and unload in each function call probably will causes me performance problems, but I'll try anyway...

Really disapointed with ActiveX...
If TActiveForm has a initialize method that can be overridden, it should also have a finalize one!

Well, perhaps someone else can bring some other ideas to this thread, but if you are saying so, I'm not so hopefulness ;-)

Thanks a lot!
Itamar
0
 
LVL 9

Expert Comment

by:ITugay
ID: 7010491
Hi itamar,

not sure for ActiveX, but usually you can do it something like this:

unit SomeUnit;
...
interface
...
implementaion
...
initialization
  // load library here
finalization
  // unload library here
end.

0
 
LVL 4

Author Comment

by:itamar
ID: 7057991
Hi inthe,

your comment was the more usefull.

Thanks,
Itamar
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi IDE crash without error message ... 7 99
LAN or WAN ? 11 95
Controlled Assessment GCSE - desperate help needed 4 98
Graphics32 under Delphi 10.1 Berlin 2 95
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question