Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing an object as parameter to a DLL

Status
Not open for further replies.

rcloutie

Programmer
May 26, 2005
164
CA
I have a ToolBar defined into the main EXE which needs to be accessed from forms within module DLLs...

2 Options:

1. Is it possible to pass an object as parameter to a DLL?
2. How to share global object variables within one EXE and DLLs?

Any idea?
 
This seems to work...
-------------------------------
ExtForm.dll
-------------------------------
library ExtForm;

procedure FormToolBar(tlbMenu: TTlbForm);
begin
tlbForm := tlbMenu;
end;
exports FormToolBar;

--------------------------------
MainMenu.exe
--------------------------------
function FormExternal(sForm: String=''): IFormInterface;
type
TFormToolBar = procedure(tlbMenu: TTlbForm);
var
hExtForm: Cardinal;

function FormExternal(sForm: String=''): IFormInterface;
var tlbExt: TFormToolBar;
begin
Result := nil;
if sForm <> '' then
begin
hExtForm := LoadLibrary('ExtForm.dll');
if hExtForm <> 0 then
begin
@tlbExt:=GetProcAddress(hExtForm, 'FormToolBar');
if @tlbExt <> nil then tlbExt(tlbMenu);
end;
if hExtForm <> 0 then
Result := FormModule(GetProcAddress(hExtForm,
PChar('Get' + sForm)));
end

else
if hExtForm <> 0 then FreeLibrary(hExtForm);
end;

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top