|
-
May 28th, 2000, 12:04 AM
#1
Why would someone create a dll? Are they just files that are full of subs and functions that can be used by different programs? And if i wrote one how would i use it?
-
May 28th, 2000, 12:28 AM
#2
Guru
Answers
There are two types of DLLs (Dynamic Link-Libraries).
- Library DLLs.
These DLLs have a bunch of functions and subs stored in them. To use them, you can use the Visual Basic Declare statement. Read about this statement in the VB help files for more information.
All the Win32 API is in Library DLLs, such as User32.DLL, Shell32.DLL, Kernel32.DLL, GDI32.DLL and many more.
Visual Basic cannot create Library DLLs.  
Because of this, it is harder to do several things, such as system-scope hooks.   - ActiveX DLLs.
These DLLs are a bunch of Class Modules which you can create using Visual Basic and other languages. It is basically like an ActiveX OCX, except the object here is a Class Module, and not a Control - only code, no (graphical) interface.
To use an ActiveX DLL, you must reference it from the VB menu: Project->References... Then, you can create instances of the Class Modules like this:
Dim MyObj As MyClass
Set MyObj = New MyClass
' A bunch of code goes here
Set MyObj = Nothing DLLs are created when you think you have some code, and don't want to share it (for free ). You can distribute the DLL, and your code will be used, but it will not be read.
I hope this makes the subject clearer...
-
May 28th, 2000, 04:26 AM
#3
Then what do i use to write a dll?
-
May 28th, 2000, 04:41 AM
#4
To write the DLL? When you start VB, select ActiveX DLL. If you want to make a simple DLL, I can give an example.
In the Class Module, put the following code.
Code:
Public Sub SayHello()
' Display a message box
MsgBox("Hello World")
End Sub
Now, create the DLL, start a new Standard EXE and add Refrence to it. to add refrence, Select Refrences from the Project Menu.
Now, add a CommandButton with the following code.
Code:
Private Sub Command1_Click()
Dim MyVar As Class1
Set MyVar = New Class1
MyVar.SayHello
Set MyVar = Nothing
End Sub
This should pop up a message saying "Hello World!"
-
May 28th, 2000, 05:52 AM
#5
Fanatic Member
Or, if you set the instancing property of your class module to GlobalMultiUse. After referencing you would only have to do this:
Code:
Public Sub Command1_Click()
SayHello
End Sub
-
May 28th, 2000, 01:56 PM
#6
Lively Member
Why DLLs??
n ofcourse the major advantage of a DLL in code comes alive at runtime! Functions in a DLL are only loaded when that function is called.!!
i.e. when u write 300 functions in an EXE the entire EXE is loaded into memory and those functions cannot be shared across processes...
But write them in a DLL and all can be accessed simultaneously by different processes... SO the Code segment loads once but the data segment loads n times.... 
Cheers
Gaurav
[email protected]
" Programming today is a race between software-engineers striving to build bigger and
better idiot-proof programs and the universe trying to produce bigger and better idiots.
So far the universe is winning". :-)
-
May 28th, 2000, 03:08 PM
#7
Fanatic Member
Which means you could write a ChimpFace.dll file that contains all of your commonly used functions and classes (like encrypt(), Sort(), Search(), FileExist() etc ) and whenever you write an app you reference it.
Why is this good?
-Code reuse (you don't have to worry about re-coding the same algorithms and objects, just look up what they pass and return in the object browser (if you forget ))
-Single point of update (updating the internals of the function later with a better performing algorithm save the exe from being recompiled)
-Smaller code distribution (If you have a package or series of exes then they all share the code and the exe's are smaller)
-They're sexy It sounds good to use them if you're a ****** like me 
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
May 28th, 2000, 09:59 PM
#8
Thank you all for replying. Now i know about dll's. In fact ive started writing one. Its only got 1 function and 1 sub, but its a start. I figure when i find a good function, ill just write it in. Well thanks...
-
May 29th, 2000, 03:14 AM
#9
transcendental analytic
I'm against Dll's, i'm always compiling everything in my project and not even fusing any dll's, i'm just writing everything by my self. Of course the common api's and vbruntimes i have to agree, i have to use but i'm not ever going to do any dll's for fun. Either i'm showing my code or not, also activeX ocx is another option.,
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 29th, 2000, 03:20 AM
#10
But when you develop a package of applications that require the same functions, you could put it in a dll to save space.
-
May 29th, 2000, 03:50 AM
#11
transcendental analytic
Yeah, but i've never done any package, and i'll probably put all compiled if i ever do so that nobody can use my code from it.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 29th, 2000, 04:50 AM
#12
But if you're making an package the size of MS office, it's best to use DLL's.
-
May 29th, 2000, 06:34 AM
#13
Fanatic Member
Well, Maybe not MSOffice size but in large projects (especially with more than one person) Dlls are a good way of sharing code workloads. Different people can work on different libraries and makes sure all passes and returns within the origional design.
Also support of segments of the code is easier to hand to a support team than just dumping everything in their lap!
But in my opinion, The BIG reason is that it forces you to build and plan better from the start. How many times have you been typing code and still thinking about design at the same time? Not a very professional construction method.
"Well, we've built the lounge room, it has doors on the east and west, Where would you like the kitchen?"
-this doesn't happen in other industires, it shouldn't happen in professional programming.
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
May 29th, 2000, 05:56 PM
#14
transcendental analytic
What's wrong with modules? I think it's a lot more comfortable when i have all the source in front of me, instead of linking to dll's containing i don't know what, but has probably a lot of bugs. And if something drains performance, it's probably because someone made a function too userfriendly and errorhandling.
When working in teams it's probably also best to have all the source available for all members, but it should be also well documented and all changes made to other's code shoud be commented.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 29th, 2000, 08:15 PM
#15
Fanatic Member
I'm talking about YOUR DLLs and your team's DLLS
The source is available to all members. But I don't hear you whinging that you don't have the source to each Win32 API!
It'd be nice to look up but how would you like that in Modules?
I'm not talking about a home user writing a tool to manage his masterbation habits in 200 lines of code, I'm talking about serious projects that you sell or are used internally with a customer base in thousands of lines, that may have to be supported in future without your presence.
The volume of code is such that it needs to be managed in a modular way, That's what OO programming is all about! The amount of code has increased such that it needs a management system built into the language.
Modules are bad for teams because programmers can call the insides directly, if you make a change to a module you created then you don't know who's code you've screwed, in classes and dlls people know the input and output, if you make a change for the better, no-one is worse off.
Thats abstraction.
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
May 29th, 2000, 08:57 PM
#16
Hyperactive Member
"I'm not talking about a home user writing a tool to manage his masterbation habits in 200 lines of code, I'm talking about serious projects that you sell or are used internally with a customer base in thousands of lines, that may have to be supported in future without your presence."
Hey how did you guess what I write?? ;-)
But I agree, in a team it's better to have dll's and ocx's then put everything in the exe (now if I only could find the word to convince my boss....)
-
May 29th, 2000, 10:15 PM
#17
transcendental analytic
No Paul I do certainly not agree.
The only thing that differs Dll's from code is that they are compiled and that is actually a restriction.
Now you were saying "Dll's and classes" So I have to tell you you can have uncompiled classmodules, usercontrols, modules, whatever you want in source, and when you compile everything in a single exe, it will run faster. So that's another restriction with Dll's.
The worst restriction is still that you have no way to debug it, because you'd probably ever have a errorfree dll.
What differing API, is that they are errorfree, thanks to microsoft.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 29th, 2000, 11:42 PM
#18
Is there anyway to view the code or see what sub and functions are in a dll?
-
May 30th, 2000, 12:44 AM
#19
transcendental analytic
ActiveX-dll's can be viewed from object browser, press F2
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 30th, 2000, 06:27 AM
#20
Fanatic Member
From what you say Kedaman, It seems odd that so much of the industry uses them.
I think you need to be on a progrmming team to see what I mean. You can't debug everyone's code, you have to trust that others are doing it right. If you had time to do that you may as well write the whole thing yourself.
Not only that, what happens if you're asked (as part of a team) to supply certain componants for the team? You make it sound like the only team you're on is where you're in charge which if often not the case.
You can pass them a dll and some documentation or 20 cls files and 5 modules and say "there you go! if you look through those 10,000 lines of code for the public bits that's what you can call, feel free to fix te bugs"
The team can look at the source if they need to but often there isn't time. If you did your job by the specification you were given then all is fine.
Another good thing about a DLL is it's independantly upgrdeable. If you have five programs relying on a DLL then that's five preograms that don't need to be reinstalled, just one dll.
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
May 30th, 2000, 06:30 AM
#21
Also, they can cut down on size a lot. If you had designed a package of 5 application's that all require a 1MB DLL file, images that you had kept them in a module. You would have 5 extra MB lying around, when you could have reduced it by making a DLL.
-
May 30th, 2000, 06:44 AM
#22
Fanatic Member
Tht's right, And one of the reasons for the VB Runtime Dlls.
Static linking causes a lot of redundant code on a system. If every VB app on my system could be static linked and was a 500k stand alone I'd have no space left
(I still want MS to implement it though )
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
May 30th, 2000, 04:02 PM
#23
transcendental analytic
I'm in charge for 2 projects and 1 partially, and we don't use any dll's, i am the one that requests component but i'm also doing debugging, so while we have all functions documented there's no need, except for debugging, to read all the lines.
If you pass a Dll containing the work of 10000 lines of code, there's probably a hell lot of bugs. If you do that with source, it's no problemo.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 30th, 2000, 04:15 PM
#24
Fanatic Member
why can't the person writing the DLL debug it?
Why should the person recieving it have to?
And since companies like Desaware sell stuff like that, does that mean all their customers debug the dlls they buy before they use them ???????????????
have you never been able to get all the bugs out of a dll before? if you have, why should any other decent programmer be able to.
Why aren't the win32 api dlls not full of bugs then? is Kedaman and microsoft the only people on the planet who can debug a dll reliably?
On the projects you oversee, is it not possible for someone else to debug the dll (if you used them) or would you have to do it?
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
May 30th, 2000, 04:43 PM
#25
transcendental analytic
Can't you see this clear Paul? Dll's are only restricting! If you don't want to read or change the source, then don't, but when you really need to change something, you have it in front of you.
Of course the person who wrote it can debug it, but this way you waste tons of time, with responding, error messages and a lot of other stuff that takes time. Ie, how do you know which line the error occurred in?
Yeah, kedaman and microsoft are two great code debuggers, but i don't see the connection. Microsoft or Desware are huge companies, I'm working in small groups.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 30th, 2000, 05:03 PM
#26
Fanatic Member
Dll's kick arse.
I'm going to have to side with Paul here and say that Dll's rock.
I am in the middle of developing a large project (50 screens and counting), and there are only two of us working on this project.
One reason we went for Dll's was speed. Obviously VB is a great language for writting a GUI, but C++ wins in speed and control.
Another reason was code reuse, and ease of maintenance. All of the database access is kept away from the GUI, so it is easier to debug. It also alows for use on the web. As this project is going to have a web implementation, as well as being a stand-alone project. The Dll allows you to call the exact same methods from ASP as VB.
And from what i have seen, Dll's are easy to debug. If i find a bug in the Dll, i just build an exe of my VB program and give it to the guy writting the Dll. I tell him what screen the bug apperaed on, and he can debug his dll, using my exe. It is most impresive.
As was stated earlier, you can see all of the available properites and methods in the object browser. I have never had such an easy time programming in VB.
Iain, thats with an i by the way!
-
May 30th, 2000, 06:04 PM
#27
Fanatic Member
Encapsulation, Abstraction.
ActiveX dlls are designed around classes. It's standard OO.
I'll admit in one off programs and tool apps I don't bother with dlls, or much OO programming. But in big projects at work I need to encapsulate. break the project up into managable bits.
I think Kedaman, If you can't see my point from all this I'm not going to convince you.
But look around you at the big projects in any language. Dll's, objects and classes, it's everywhere, from the API we VB programmers love to call to the references we put into out programs from all sorts of third party groups.
I've seen you're page and your code is good, your algortithms are fast. But it's more like snippits than modular code. Great for you because you wrote it but very difficult for someone else to use in a project unless they want to read every line. You couldn't sell it in that form.
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
May 30th, 2000, 06:28 PM
#28
transcendental analytic
Hehe, Paul, what makes you think, i'm not working with OO? I use classmodules all the time, but i always compile the INSIDE my exe not UTSIDE.
Iain had a point there, you can use dll's compiled with C++, because they're great in performance, but doing ActiveX dll's won't make any gain in speed.
Well, i have one class on my homepage, (i converted it into class from a module code). But do you know why i have the most code there in modules?
That's because we have so many Vb-newbies here to download them.
I have nothing against classes and object, i love them and my applications love them
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 30th, 2000, 08:29 PM
#29
Hyperactive Member
If your dll's are not bug-free you should debug them before you compile and spread it around. If you're forced for some reason to use a dll of which you can't access the code, and can't go to the ppl who do have access to the code, either live with it or write it yourself.
And no, the API is definitely not bug-free, but it's not bad. Yes tnx to M$, they have a large team of developpers and testers, and that's the only way, Testing, testing, testing, before you release something. Easy.
And why do you think they (M$) created the API in dll's, and not release it in typelibraries or something so that it can be compiled in the exe? Easy, one dll is easier to replace then recompiling all the programs that are using the dll.
-
May 30th, 2000, 09:25 PM
#30
kedaman,
i don't want your compiled DLLs without source code, because that way i cannot compile them into my 150 MB exe and debug them. i think, i am the only one able to debug.
why do you expect others to use your DLLs and refuse to use them yourself?
-
May 30th, 2000, 09:48 PM
#31
Fanatic Member
Hey, Leave Kedaman alone !!!
He's finally coming around to our point of view 
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
May 30th, 2000, 10:45 PM
#32
transcendental analytic
Of course of course, but here's why I am i agreeing, i'm thinking of making some dll's, for you to use, without having my source known to others
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 30th, 2000, 10:49 PM
#33
Addicted Member
roflmao@Sascha. Stop it, people here at work are starting to wonder why I laugh at myself.
-
May 31st, 2000, 03:48 AM
#34
Of course of course, but here's why I am i agreeing, i'm thinking of making some dll's, for you to use, without having my sourceknown to others
Another reason why DLL's are better!
-
May 31st, 2000, 04:33 AM
#35
Guru
You want reasons! I'll give you reasons!
What if a program weighs about ten megabytes (EXE only, no other files), and the author spotted a really big bug, fixed it (about 10KB were changed), and redistributed the application?
Would you like to download ten megabytes for a 10KB change?
What if the author created about 9 different DLLs, making each file a megabyte?
Your download would be a tenth of the size - the author wouldn't update all the files for one bug.
Another reason to use DLLs, is, you can tell your friend at school (do any of you still go to school?), "I just built a 32-bit application which uses subroutines and functions from a personally-developed dynamic link library," and he/she will think you are so smart! (Well, you probably are, but now you can prove it)
-
May 31st, 2000, 05:39 AM
#36
-
May 31st, 2000, 05:52 AM
#37
Code:
if(Yonatan == TRUE)
{
Kedaman == FALSE
}
else
{
Kedaman == TRUE
}
-
May 31st, 2000, 06:05 AM
#38
Fanatic Member
-
May 31st, 2000, 06:36 AM
#39
Hey, Paul. I took your advice and added my VB version to my signature!
-
May 31st, 2000, 06:49 AM
#40
Fanatic Member
Good,
Now I know not to post any code to you with a split() function in it!

Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|