Page 1 of 2 12 LastLast
Results 1 to 40 of 50

Thread: DLL's

  1. #1
    Guest

    Post

    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?

  2. #2
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892

    Exclamation 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...

  3. #3
    Guest
    Then what do i use to write a dll?

  4. #4
    Guest
    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!"



  5. #5
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    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

  6. #6
    Lively Member
    Join Date
    May 1999
    Location
    India
    Posts
    97

    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".
    :-)

  7. #7
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840

    Thumbs up

    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!)

  8. #8
    Guest
    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...

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  10. #10
    Guest
    But when you develop a package of applications that require the same functions, you could put it in a dll to save space.

  11. #11
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  12. #12
    Guest
    But if you're making an package the size of MS office, it's best to use DLL's.

  13. #13
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840
    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!)

  14. #14
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  15. #15
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840

    Exclamation

    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!)

  16. #16
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Rotterdam, Netherlands
    Posts
    386
    "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....)
    Hope this helps

    Crazy D

  17. #17
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  18. #18
    Guest
    Is there anyway to view the code or see what sub and functions are in a dll?

  19. #19
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  20. #20
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840
    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!)

  21. #21
    Guest
    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.

  22. #22
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840

    Thumbs up

    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!)

  23. #23
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  24. #24
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840
    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!)

  25. #25
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  26. #26
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658

    Thumbs up 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!

  27. #27
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840

    Cool

    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!)

  28. #28
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  29. #29
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Rotterdam, Netherlands
    Posts
    386
    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.
    Hope this helps

    Crazy D

  30. #30
    Guest
    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?

  31. #31
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840
    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!)

  32. #32
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  33. #33
    Addicted Member
    Join Date
    Mar 2000
    Location
    Gainesville, FL
    Posts
    131
    roflmao@Sascha. Stop it, people here at work are starting to wonder why I laugh at myself.

  34. #34
    Guest
    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!

  35. #35
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892

    Exclamation 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)

  36. #36
    Guest
    YA, YONATAN'S RIGHT!!!!!

  37. #37
    Guest
    Code:
    if(Yonatan == TRUE)
    {
       Kedaman == FALSE
    }
    else
    {
       Kedaman == TRUE
    }

  38. #38
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840
    See Kedaman!

    Even the school kids can see it

    Talk to you all later...

    Paul Dwyer
    Network Engineer
    Aussie In Tokyo

    Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)

  39. #39
    Guest
    Hey, Paul. I took your advice and added my VB version to my signature!

  40. #40
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840
    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!)

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width