Solved

Export Rec/Var from DLL

Posted on 1998-03-24
6
173 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
Technology Partners: 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

729 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