Solved

Export Rec/Var from DLL

Posted on 1998-03-24
6
167 Views
Last Modified: 2010-04-06
I need data from a DLL (a Record and some Variables) in 4 units. I know how to export procedure and functions, but i can't access the record and the variables from these units.
0
Comment
Question by:omsec
[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
  • 4
  • 2
6 Comments
 
LVL 4

Accepted Solution

by:
d003303 earned 30 total points
ID: 1360811
Yo,
all variables in a DLL are private to the DLL itself. To pass these variables between different modules (DLL/EXE, DLL/DLL) you need to use a procedural interface.

Slash/d003303
0
 
LVL 2

Author Comment

by:omsec
ID: 1360812
do u mean, i shall write a procedure that do assigns the variables with data (initialize) and then export the whole thing to the host-program ?
0
 
LVL 4

Expert Comment

by:d003303
ID: 1360813
Something like that :
library xyz

// stuff...

var MyVar : TMyStruct;

function GetMyVar: TMyStruct;
begin
  Result := MyVar;
end;

procedure SetMyVar(NewVar : TMyStruct);
begin
  MyVar := NewVar;
end;

// export these two

// or another way would be

var MyVar : TMyStruct
    MySecondVar : TAnotherStruct;

procedure GetMyVars(var FirstVar : TMyStruct; var SecondVar : TAnotherStruct);
begin
  FirstVar := MyVar;
  SecondVar := MySecondVar;
end;

procedure SetMyVars(FirstVar : TMyStruct; SecondVar : TAnotherStruct);
begin
  MyVar := FirstVar
  MySecondVar := SecondVar;
end;

// and export these two.

Slash/d003303
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:d003303
ID: 1360814
To clarify, I assumed these functions are called fromout the host application.
0
 
LVL 2

Author Comment

by:omsec
ID: 1360815
yeah, i see what you mean there. but something makes that a lil difficultm, cos i have to export a record, well this isnt really the probrlem, but four of its fields are arrays. do ya want me do email you the dll-project ?
0
 
LVL 4

Expert Comment

by:d003303
ID: 1360816
If you declare the record you are passing in your DLL and EXE, it should not be a problem. Many Win32API-structures are nested structures, and the API calls are all DLL interfaced.
E.g. create a unit that only declares the types you are using in your DLL and EXE in its interface section, and place it in your DLLs and EXEs uses clause.

Slash/d003303
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
When I am typing into a TEdit last word repeats 7 160
Drag & Drop... Data from one grid to another 2 47
DBCtrlGrid, Delphi, Scroll 7 32
IP without any Dots 1 53
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

756 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