Solved

Loading DLLs in my own thread???

Posted on 2002-07-13
7
187 Views
Last Modified: 2010-04-04
Hi
i would be very gratefull to hear from any one who knows about loadig DLLs in a specific TThread.
*******NOT IN MAINTHREAD*********
thanks in advance :)
NIMA
0
Comment
Question by:Mohamadi
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
No problem, just do it, works fine.
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
P.S: May be different, though, if the DLL has own forms in it. Never did such a thing yet...
0
 
LVL 1

Expert Comment

by:Dumani
Comment Utility
LoadLibrary('c:\mypath\mydll.dll');
will work fine
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 12

Expert Comment

by:Lee_Nover
Comment Utility
if you take a look at the Main function of the dll you can see it has one Reason parameter
it can have 4 values:
PROCESS_ATTACH, PROCESS_DETACH, THREAD_ATTACH, THREAD_DETACH
so you really can load a dll in a separate thread
as madshi pointed out there might be some roblems if you have some forms in there
a better way of using forms in your dlls is to make a package instead of a dll
0
 

Author Comment

by:Mohamadi
Comment Utility
can you tell me an example??
thanks alot
nima
0
 
LVL 12

Accepted Solution

by:
Lee_Nover earned 100 total points
Comment Utility
type
  TFunction = function(x: Integer): Integer; stdcall;

...
var
  Func: TFunction;
  hLib: Cardinal;
  param, result: Integer;
begin
  hLib:=LoadLibrary('mylib.dll'); // load the dll dynamically
  if hLib = 0 then exit;
  try
    // now get our functions entry point
    @Func:=GetProcAddress(hLib, 'TheFunctionName');
    if @Func <> nil then
      result:=Func(param);// simply call out function var as we would any other function
  finally
    FreeLibrary(hLib);
  end;
end;

this will call the Func in the calling thread
this way the library is always loaded in the calling processes memory !

a more exact explanation here :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/dll_1o8p.asp

0
 

Author Comment

by:Mohamadi
Comment Utility
Thanks alot :)
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now