CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: DLL and EXE

  1. #1
    Join Date
    Aug 2000
    Location
    South Africa
    Posts
    195

    DLL and EXE

    I'm new to all this ActiveX technolgy and I'd like to ask a few questions:
    1) When do I use a DLL and when do I use a .EXE?
    2) I take it that with a DLL I can have forms in my project? With a .EXE not?
    3) I get mixed up when Dim CNEW AS NEW CLASS must be added to the project - Declarations or when an instance of the COM is created?
    4) When do I create a .Bas module and set is as startup?

    Thanks!




  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: DLL and EXE

    dll are in process components, activex exe are out of process components. That means, you use dll when you do not plan to have remote components (components running on other machines consuming those machines resources instedad of yours). This is in general (Com and DCom technology), but you can make remote components as Dll if you use, for example, MTS. And you may build an activex exe which run on your machine as the other dll and standard exe...
    You may have forms in dll and in activex exe. Be careful when using, as your components will have matter on closing if one of those forms does not unload and set to = nothing...
    Dim CNEW AS NEW CLASS is a bit dangerous: it means a new instance of CLASS is created every time in your code you refer to it. I do prefer to code
    (it is only the way I am used, but as sintax supports the previous, I must think there should be plenty of situations where you could prefer the first)

    dim CNEW as CLASS
    and, where I need:
    set CNEW = new CLASS 'if new instance is required every time
    or
    set CNEW = CLASS ' if only 1 is required
    ...
    and then
    set CNEW = Nothing
    to terminate the instance and do not forget "open" components

    Sometimes it happen a standard exe should starts form Sub Main added to a bas module. It never happened in a DLL or activex Exe (you have the initialize event of a class for that),. Cases where when proigram should act differently in case a parameter was passed at start up (search for "Command$" in help), or to set compiled options (search for "#If" in help), or to search for previous instances of program and if found exit the standard EXE before showing windows or load heavy components (pure code is quicker).
    So far for my knowledge. Let's see if someone else add.
    Best regards,
    Cesare Imperiali





    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

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

Featured