Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Loading DLLs in my own thread???

Posted on 2002-07-13
7
Medium Priority
?
195 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
[X]
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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 300 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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 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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

688 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