Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What can be done in DLL's 3

Status
Not open for further replies.

x508

Programmer
Jun 26, 2003
396
ZA
Hi, I have incorporated a LOT of functionality in my application and I have recently looked through all of my code and realised that it is very "untidy", probably due to the fact that I am learning better and newer techniques all of the time, this being said...

What can DLL's be used for. I know it acts as an independant library, to which you can pass instructions, and receive their corresponding answers.

The problem to me is that most of my code that I would like to put in a DLL, makes heavy use of my GUI.

I.e. I would like to write a DLL which sends my e-mail (through Winsock), but where will I get the winsock control if i'm working in a dll, where/what/how do I replace my current timers etc.

Any ideas or views?

**********************************
May the Code Be With You...
----------
x50-8 (X Fifty Eigt)
 
x508

I use dll's in most of the app's I write. There are two major reasons why I prefer to write dll's. One is that it hides a lot of of code and keeps it seperate from the application at hand. All of the app's I generate are database driven and to me it keeps my apps more organized and clean when the database code is kept seperate of the application. The second reason I choose to code my d/base code in a separate dll is if for any reason the database connectivity changes ie. from Access to SQL Server, all if have to do is change a few lines of code in the dll, recompile, and I am done.

Hope this gives you some ideas for your apps.

Tom

Tom (maxflitom)
 
maxflitom, so when you Recompile DLL, do you have to Register DLL again?

I am always confused about DLLs.
When you create DLL's, do you have to register them on your machine? or its done automaticall via VB?
We only have to register them on Client Machines?

Thanks.
 
highwingers,

There are a few options to registering dll's. The first and most simplist is when you have the Project loaded in VB, choose 'Create (filename).dll' from the File menu in VB. The dll is automatically registered on that PC. So if the app using that dll will recognize it automatically and the GUID's entered in the Registry.

If the dll is part of the app you are writting to be installed on another machine, you should include it when you Package your app using the Package & Deployment Wizard. This will install and register the dll that machine. FYI, don't forget to include a Dependancy File.

Another way to register a dll is using the regsvr32 utility. From a DOS window, type regsvr32, the path, and dll filename. For example: regsvr32 a:\Temp\mydll.dll.

Hope this helps.

Tom

Tom (maxflitom)
 
And I dont See Package Wizard under my VB, Do I need to add it or its under some mysterious Menu?
 
highwingers

There are two ways to get to the Package and Deployment Wizard. The first if through VB. Go the the Add-Ins menu and choose Add-Inn Manager, next click on Package and Deployment Wizard (you can double click also), under the Load Behavior frame check Loaded/Unloaded, or if you wish to have P&D load each time VB starts, check Load on Startup and choose OK. You can now access P&D from the Add-Ins menu.
The second way is to close VB, press Start, Programs, Microsoft Visual Studio, Microsoft Visual Studio Tools, and select Package and Deployment Wizard. You can also package your application using scripts and using a command line prompt but I won't discuss that for now.

Dependancy Files are created using P&D. Search for Dependancy File for more info. A Dependancy File lets VB know which run-time components your application is dependant on or must use in order for it to function properly such as 'MSADO15.dll' or for your application, the name of your dll file. It is a good practice to generate a Dependancy File before compling your dll or application.

To create a Dependancy File choose the Package and Deployment Wizard under the Add-Ins menu. Next select Package and for the Package Type select Dependancy File from the ListBox.

Hope this helps,

Tom

Tom (maxflitom)
 
Ok lets explain the difference between DLL's in VB (ActiveX DLLs) and standard DLLs
standard DLLs are normally like function libraries.

ActiveX DLLs can have forms just fine. You access these forms normally by calling classes (you can actually do it a bit different but this is the norm.)

So maybe you tie a class to your form. Instantiate the class, it show's the form (maybe modally) does its job and returns the information.

Its hard to explain in a short post but you can use ActiveX DLL to modularise your applications. If you design them well then the interface can be set and you can upgrade the DLL if you find a better way to do a job. Just as long as the information going to and from your program to the dll doesn't change you will not have to reregister the DLL. You do have to register them on and machine you need to use them on but if you make up a setup program for you main application this should take care of that for you.

Hope I've been helpful,
Wayne Francis

If you want to get the best response to a question, please check out FAQ222-2244 first
 
All fair enough...

let me get more down to the point.

First of all, Wayne. I don not understand how you would use a form from within a DLL(which does not have an interface)

Second: Will I be able to use controls such as the winsock and timer controls within a DLL

**********************************
May the Code Be With You...
----------
x50-8 (X Fifty Eigt)
 
Open a new project, select active-x dll. Goto Project->Add Form and add a new form, your dll now has an interface.

Yes you can use controls in your dll, anything you like.

May I point you in the direction of a tutorial...


It is in three parts, the other links available from the above link. I havent read it in full but seems quite good to learn from, and it comes with a very simple sample project.
 
Excellent. I'll do so.

Before I go and try it, cause it will only be tonight, can I then just pop up my forms from my dll like in a normal exe

In dll ******

frmWhatEver.show

??

**********************************
May the Code Be With You...
----------
x50-8 (X Fifty Eigt)
 
You will see, and as already explained above the dll is accessed by referencing procedures in a class file within the dll, have a look at the project and understand how it works and yes, you could add a procedure that simply displays a form with the code... frmWhatEver.show (After you add frmWhatEver to your project of course!)

I think once you have a look at that sample a lot of your queries will be explained and you will find dll's ocx's and a-x.exe's quite easy

Good luck
 
The example is not the one I had in mind, anyway check out the tutorial and I'll see if I can find a good example
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top