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