Solved

Dll, FreeLibrary and Sharemem

Posted on 2003-12-05
3
457 Views
Last Modified: 2010-04-05
Hi

Here is a code that I am trying to call a procedure from a x dll.
procedure Test;
var
i: integer;
Module: THandle;
msg: TPlugProc;
begin
i:=0;
with PlugList do
 while i<Items.Count do
  begin
    Module:=SafeLoadLibrary(PChar(plugInsDir+Items[i]));
   try
     @msg:=GetProcAddress(Module,'MyMessage');
     if @msg<>nil then
       msg;
   finally
    if Module<>0 then
      FreeLibrary(Module);
   end;
  i:=i+1;
  end;
end;

I have problems with FreeLibrary if I add Sharemem in uses clause as it describes in Borland dll project. If Sharemem is not added then it works.
Can someone explain why?
Can it be any problems without Sharemem?
Some suggestions?

thanks,
mha
0
Comment
Question by:michaenh
  • 2
3 Comments
 

Author Comment

by:michaenh
ID: 9881721
Hi again delphi lovers.. :)

If I use FastSharemem instead of Sharemem then it works..

cheers,
mha

0
 
LVL 8

Accepted Solution

by:
gmayo earned 30 total points
ID: 9881777
You only need ShareMem if you share data between the app and the DLL. This includes string types. PChar is okay without ShareMem.

Geoff M.
0
 

Author Comment

by:michaenh
ID: 9881820
Hi.. :)

>You only need ShareMem if you share data between the app and the DLL.

Yes I do share data between the app and the dll.
Instead of Sharemem I now use FastSharemem.

thanks,
mha
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 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

19 Experts available now in Live!

Get 1:1 Help Now