Solved

Loading DLLs in my own thread???

Posted on 2002-07-13
7
190 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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
Best Firemonkey component pack 1 119
Delphi : could not find program, '...exe' 2 193
Delphi Form ownership 4 114
Tidtcpserver listening on multiports? 1 35
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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 …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

828 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