Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Regarding .dll's

This topic is 5450 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

''K, so, anyone watch Lingo? (For those who don''t: you have 5 tries to guess a 5 letter mystery word. they give you the first letter and you keep trying to guess the word. they highlight the letters correctly placed in red, and letters that are out of place in yellow. Example: lets say mystery word is BINGO you are given letter b and you guess: BOATS -- o is out of place highlighted in yellow... BIMBO (is that even a word?) -- b,i, and o in correct spot highlighted in red BINGO -- all letters in correct spot all in red Get the idea?) Anyhow, im trying to recreate Lingo, in a chappy DOS version (i''m only a beginner). However, here is my problem... i have a list of all acceptable 5 letter words i need for this project in a .txt . Im planning to insert the entire list into a .dll file named words.dll, however im not too sure how to do it. i never worked before with dll''s, dunno how they work. i read all i could about dll''s and i heard of the _declspec(dllexport) thing, but im not sure how to link the .exe to the .dll, so.... Anyone here know about .dll''s, i''d really like some help.

Share this post

Link to post
Share on other sites
To be perfectly honest, I think dlls are a bit much for the program you''re explaining. It''d be much easier and just as effective to work on file handling and just read in the text file itself. If so, look into functions like fopen, fgets, and the like (assuming you''re using C++) ignore this if you mean it as a way of practicing dlls specifically... but i just need to warn you they''re excessively complicated for something that simple.

-Arek the Absolute

Share this post

Link to post
Share on other sites
This is indeed a way to practice .dll''s. Sometime far off in the future i''m planning a game that will excessively use .dll''s to the point where I''m sick of them. I have no good resources for writing .dll''s in my "Beginner" books, so at this point im totally clueless about how to start.

So, first the basics...
Does the source file for a .dll have the same structure as a regular source file for a non-dll file? My book vaguely mentions DllMain(), which honestly i have no clue what it is. Do i use regual int main() or the DllMain()?

BTW. i''m not planning on using any MFC in here.

Share this post

Link to post
Share on other sites
DllMain is the entry point of a dll when teh dll is opened. When you open up a dll, teh first function that is called is DllMain. You dont have to have it there though.

Using a DLL for this is indeed a bit overkill, but anyway, steps:

- Create a new empty DLL project.
- Make a header with function prototypes starting with __declspec(dllexport) so that the compiler knows that these functions need to be exported
- Make a CPP file with the function definitions. No need for __declspec(dllexport)
- Make a function that you want to return the strings in a n array or something.
- Make sure any memory you create in the dll, you also destroy in the dll
- when you comile you will get a .dll file and a .lib file.
- Now move the header file over to you Lingo project directory and include it in your program.
- change __declspec(export) to __declspec(import) so that the compiler knows that it will be getting these fuctions from a lib.
- Include the lib (the one that was created in the dll project) in your project so that it can compile
- now add the .dll to your project directory and run the program. The exe needs the dll to run, and the compiler needs the .lib to compile


.h file

__declspec(dllexport) InitializedMemory();
__declspec(dllexport) std::string* GetWords();
__declspec(dllexport) void DestroyMemory();

.cpp file

std::string* mywords = 0;

void InitializedMemory()
mywords = new std::string[5];
mywords[0] = "BINGO";
mywords[1] = "OVERKILL";
mywords[2] = "TOOMUCH";
mywords[3] = "EXCESS";
mywords[4] = "SURPLUS";

std::string* GetWords()
return mywords;

void DestroyMemory()
delete [] mywords;

| C++ Debug Kit :: GameDev Kit :: DirectX Tutorials :: 2D DX Engine | TripleBuffer Software |
| Plug-in Manager :: System Information Class :: D3D9 Hardware Enum | DevMaster :: FlipCode |

Share this post

Link to post
Share on other sites
Wow, actually I''m really glad this was brought up... you successfully summed up in one post a topic that I have personally had a very hard time finding concrete information about! =) =) Well done =)

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!