An almost complete DLL guide! |
| | | | Submitted on: 9/3/2003 10:42:42 PM
By: D Davis
Level: Intermediate User Rating:
By 31 Users Compatibility:C++ (general), Microsoft Visual C++
Users have accessed this article 10831 times. | (About the author) |
| | + Creating ActiveX DLL's in VB (and compatability issues),<BR> + Creating DLL's in C++,<BR> + Using ActiveX DLL's in VB apps,<BR> + Using Non-ActiveX DLL's in VB app and C++ apps,<BR> + Loading DLL's DYNAMICALLY in both VB and C++ (Good for plug-ins),<BR> + Calling a function by a string (Good for scripting programs). <p>
This article was written for alot of reasons. For one, I needed to learn how to load and use DLL's and get a better understanding of doing so. Another was because there are so many shxtty examples out there today it's not even funny. Plus I found ZERO information on most of the stuff I go over. Every tutorial I've seen on how to make a DLL covers making one, then using the 'Declare' statement to utilize them. Not any good for plug-ins. Plus, the other half of the tutorials didnt even work! Anyways, I wrote this to try and sum up all of the half-ass tutorials and the complex, cryptic information and fill in the non existant information. I try to explain as best as I can. I know there might be slight changes that have to be done in order for it to work with you, but so be it. Make them and write about it to teach others. <P>
I hope that this gives everyone a better idea of how to use DLL's and add flexability to their applications/games. | |
|
Download article
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.
Virus note:All files are scanned once-a-day by Planet Source Code for viruses,but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE: 1)Re-scan downloaded files using your personal virus checker before using it. 2)NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com
|
Terms of Agreement:
By using this article, you agree to the following terms...
1) You may use
this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
2) You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
3) You may link to this article from another website, but ONLY if it is not wrapped in a frame.
4) You will abide by any additional copyright restrictions which the author may have placed in the article or article's description. |
Other 1 submission(s) by this author
|
|
|
Report Bad Submission |
|
|
Your Vote! |
See Voting Log |
|
Other User Comments |
9/3/2003 10:51:20 PM:D Davis Yes, I did post this in two categories
since it deals with VB and C++.
|
9/4/2003 4:46:08 AM:Psyc very good article.. thanks! :) [5 glbs]
|
9/5/2003 2:14:42 PM:maniac very nice, 5 from me
|
9/7/2003 8:00:23 AM:Ali Akbar Excellent Article. Thanks.
|
9/7/2003 12:21:30 PM: very nice, i was wanting to learn some
of that stuff
|
9/10/2003 4:38:01 AM: Very useful article, with useful
information.
|
9/11/2003 5:27:36 AM:John Bell Umm, stdafx? ack....I prefer the hard
way. If you want info on loading dll's
into other processes(cross-task
subclassing) I submitted an article on
how to do this for aol. fallenhobit is
the name its submitted under. Peace.
|
9/11/2003 10:13:38 AM:D Davis I agree! I only used the stdafx for
easy setup purposes. that's it. I
prefer the hard way as well!
|
9/12/2003 2:17:31 PM: Thanks for the article! I've been
wanting to do some of this myself and
this will at least get me started
before I head off into the dark...
|
9/16/2003 4:08:12 PM:John Mikhaiel just wanted to let you know that in the
Accessing you Dll Code, before the end
of the process, its better to include
the following line:
Set MyDll =
Nothing
to free it up this way itll
free up memory wit it, and its unloaded
properly. the reason y i think it
should be included is cause you also
included the loading process
(CreateObject) so if the code loads it,
it should unload it. not tryin 2 be
smart or anythin.
|
9/16/2003 4:20:36 PM:John Mikhaiel also for users of older vb
versions:
vb5 supports ActiveX Dlls,
and the 32bit version of VB4 (but
ActiveX Dlls were called OLE Dlls). the
16bit version of VB4 supports only
ActiveX EXEs which if written correctly
are the same as the Dlls but can also
be stand-alone programs (NOTE That vb4
16bit is only good for compatibilty
with windows 3.1 and is pretty useless
otherwise, vb4 32, and 16 are on the
same installation CD).
|
10/9/2003 7:11:19 PM:Jonathan Ho Just what I needed. Very concise. 5
from me!
|
12/3/2003 4:47:30 PM:Wolf McCloud I don't really see the use of this for
me but it looks nice for beginners that
can't learn by themselves... I'll vote
like other people. :)
|
12/3/2003 5:05:30 PM:D Davis This article was meant for people who
have never been involved in complex
projects, or have no experience with
design docs. Hopefully it didnt come
off as a guideline for experts as well
as it was not intended to be. It's
basically a place to start for those
who have never worked in organized
projects.
|
12/25/2003 6:51:49 AM:mugman21 PART 1:
Great Job, this is a very
nice piece of work.
First, when
calling the dll, there is no need for
all the fancy api calls (load library,
getprocaddress,freelibrary yada yada
yada). Just do this... In your dll,
change:
int MyDLLFunc1()
{
MessageBox(NULL,"My DLL Function
1","",MB_OK);
return
true;}
to:
int _stdcall MyDLLFunc1()
{
MessageBox(NULL,"My DLL Function
1","",MB_OK);
return true;
}
|
12/25/2003 6:52:20 AM:mugman21 PART 2:
NOTE THE KEY PRASE "_stdcall"
I ADDED!!!
After that is done, you can
call the dll normally, like
anyother.
For example, in vb just do a
"Private|Public declare function
MyDLLFunc1 lib "The_DLL_Name" () as
long" This goes for C++ as well. This
makes it a lot easier. As you can see,
in vb after you declare the api to call
it you only use it's
name:
Command_Click()
MyDLLFunc1
End Sub
One thing you
mentioned in your article is the use of
.def files. I use that method myself,
but if I recall correctly, you said you
did not know of any other way to export
functions. This function
__declspec(dllexport) allows you to do
it without creating a .def file. I
never use it, although it supposedly
creates a smaller dll.Thanks for your
submission, and hope you release an
updated article soon, thanks and take
care.
|
12/25/2003 7:09:51 AM:mugman21 One more thing, the dll needs to be in
the app.path directory, the
winnt|windows dir, or the system32 dir.
D Davis, I hope you would release an
update to this article soon, I think
what you created was excellent.
|
1/19/2004 9:07:05 AM: Listen to this dude he knows what hes
talking about, ok
|
1/27/2004 3:03:28 AM:RAJENDRA Very helpful articles
|
|
Add Your Feedback! |
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.
NOTICE: The author of this article has been kind enough to share it with you. If you have a criticism, please state it politely or it will be deleted.
For feedback not related to this particular article, please click here. |
|