Solved

Export Rec/Var from DLL

Posted on 1998-03-24
6
158 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
  • 4
  • 2
6 Comments
 
LVL 4

Accepted Solution

by:
d003303 earned 30 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 4

Expert Comment

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

Author Comment

by:omsec
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now