Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

HOW TO READ A STRING FROM DLL?

Posted on 1999-07-26
7
Medium Priority
?
137 Views
Last Modified: 2010-04-04
Situation: Form1 with Memo1 and Combobox1, DLL "DATES.DLL"

Desc:
I am creating a simply chronicle, which contains the names of famous people in Combobox1. When the user clicks on some name, the program reads the data for selected name from DLL "DATES.DLL" into Memo1. How to:

(1) create and prepare the strings in DLL for export and

(2) how to call the string from my program (i.e. when user clicks on William Shakespeare, the program reads a string Shakespeare1 in DLL)?

Step by step, please, I am not so good in Delphi (I use Delphi 3).

THANKS!
0
Comment
Question by:pipigril
[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
  • 3
7 Comments
 
LVL 10

Accepted Solution

by:
viktornet earned 280 total points
ID: 1391241
Create a resource file with your strings, include that resource file in your DLL like so.

{$R MYRESOURCEFILE.RES}

then, from your unit after you call LoadLibrary() call LoadString() and pass it the handle from the LoadLibrary() function and that should do it..

..-=ViKtOr=-..
0
 

Author Comment

by:pipigril
ID: 1391242
Hmmm... Very good, viktornet. Before I accept your answer, please tell me: How to use LoadLibrary and LoadString? These commands I don't know.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1391243
okya example...

var
  hlib : hinst;
...

hlib := loadlibrary('MYDLL.DLL');

//then you use the loadstring()

ShowMessage(LoadString(hlib, 'str1'));

if hlib > 0 then FreeLibrary(hlib);

btw, you might wanna use FindResource() and so on, so you can find the resource from within the DLL... if you use only a resource file, it is not needed most of the time...


If you need more help please let me know, k? ;-))

..-=ViKtOr=-..
0
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!

 

Author Comment

by:pipigril
ID: 1391244
Thanks... But how to create a RES file with strings? Image editor doesn't support editing strings.
0
 

Author Comment

by:pipigril
ID: 1391245
Thanks... But how to create a RES file with strings? Image editor doesn't support editing strings.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1391246
create a text file, and put the following in there..

STRINGTABLE
BEGIN
  1, "help"
  2, "not help"
END

save it and make the extension be RC... e.g. MyResourceFile.RC

now go to Delphi's Bin directory ad find BRCC32.EXE,. you have to compile this MyResourceFile.RC with that EXE file... it will generate a RES file then// so now you will have a file named MyResourceFile.RES

in order to include it in your unit do this.,

{$R MyResourceFile.RES}

and you're ready to use it.. you can include the above statment in a DLL so the resources will be in the DLL..

Good Luck!!

..-=ViKtOr=-..
0
 

Author Comment

by:pipigril
ID: 1391247
GENIAL!!! THANK YOU VERY MUCH!!!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

661 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