Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2007 May : Global Unit

www.cryer.info
Managed Newsgroup Archive

Global Unit

Subject:Global Unit
Posted by:"Churc" (cebas..@gmail.com)
Date:2 May 2007 12:12:45 -0700

Hello!

I have a Global Unit, like a API unit to share somethings to any
Applications!

Code

But, when "Application A" load a DLL using the following code:

unit MyGlobalUnit;

interface

uses
  Windows, ...;

type
  TMyFunctionExample = record
    Func: function (Params: Integer): BOOL; StdCall;
    hHandle: THandle;
  end;

  Function SomeCodeToLoadThatFunction(Params: Integer): Boolean;

var
  MyFunctionExample: TMyFunctionExample;

implementation

Function SomeCodeToLoadThatFunction(Params: Integer): Boolean;
begin
  Result := False;
  with MyFunctionExample do
  begin

//Here we check if the DLL is already loaded!
    if hHandle = 0 then

//If not then we load
    hHandle := LoadLibrary(PChar('mydll.dll'));

    if (hHandle <> 0) then
    begin
      @Func := GetProcAddress(hHandle, 'MyFunctionExample');
      if Assigned(Func) then
      Result := Func(Params);
    end;
  end;
end;


Ok there is no problem...

But my question is, this Unit was loaded by "Application A", when some
Application, like "Application B" will load that Function it'll load
the DLL again correct? Since there is not way to share the same DLL
handle to 2 differents application correct?

Stupid question, anyway ehehe

Best Regards,
Carlos

--

Glossary

File Types

Replies:

www.cryer.info
Managed Newsgroup Archive