Solved

Loading DLLs in my own thread???

Posted on 2002-07-13
7
189 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
ID: 7151204
No problem, just do it, works fine.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 7151205
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
ID: 7151295
LoadLibrary('c:\mypath\mydll.dll');
will work fine
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 12

Expert Comment

by:Lee_Nover
ID: 7151678
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
ID: 7156649
can you tell me an example??
thanks alot
nima
0
 
LVL 12

Accepted Solution

by:
Lee_Nover earned 100 total points
ID: 7156782
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
ID: 7171303
Thanks alot :)
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PDF library for Delphi 2 119
Machine not responding during CopyFile() 3 98
Reconfigure Delphi Install? 2 51
How to load 2 images in same column in Delphi 2 45
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

813 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