Click to See Complete Forum and Search --> : Why to use Dll?


Geetika Malik
March 18th, 2001, 02:43 AM
Is it efficient to create dlls for a software than class modules/modules for non system level programming? Does more dlls affect the performance of the code and can cause it to crash? Do we have other alternatives?

Cakkie
March 18th, 2001, 06:53 AM
Here are some reasons why DLL's are used, and why not:

- Code reuse, a dll can be called from any one application, so if you have some functions U use in deiiferent applications, DLLs are the way to go.

- Updating. When updating a program wich uses DLL's, you can update only those files wich need to be updated, this can reduce the size of you rupdate program drastically. If all was compiled to 1 exe, the file would be bigger, and would take longer. This is very useful when distibuting via the internet.

- If using DLLs, you must be careful with what you change. If other programs use your dll, you must be sure that when u change your dll, the other programs will continue to work. Say you add a parameter to a function, if the old program doesn't know of this, it will crash when using the function.

- Speed isuues, this is a double edged knife, if you use DLLs, the DLLs are loaded when needed (wich is good). This will cause your program to start faster, but I will take longer when the dll is used for the first time. When not using a DLL, the program starts slower, but will be faster when a class is needed.

I hope this gives you an idea wheter or not to use DLLs.

Tom Cannaerts
slisse@planetinternet.be

The best way to escape a problem, is to solve it.

Geetika Malik
March 19th, 2001, 11:14 AM
Thanks for the speedy reply!!
But still I have doubt, that, do dlls cause more memory usage and resource utilization?
And more use of dlls makes the software vulnerable to crashes?
Thanks again.

Cakkie
March 19th, 2001, 02:14 PM
The use of DLLs uses a bit more resources, but in most cases, this won't be more than just a few milliseconds.
A dll doesn't increase the risk for crashes, actually, it is safer because they run out of process. When it crashes, it will only crash the process it is running in, not the entire computer, so you can consider this even safer than running it in the app itself.

Tom Cannaerts
slisse@planetinternet.be

The best way to escape a problem, is to solve it.

kevin shen
March 19th, 2001, 06:32 PM
Right now I am choosing language to program between VB and VC++. The most concern is running speed.Do you think the runnung speed to use VB to call algrism dll slower than the speed use VC++? Or the speed couldn't different too much? Thanks!

Best Regards,

Kevin Shen

Cakkie
March 20th, 2001, 09:32 AM
C++ dll's are known to be faster, but this will only be noticed with very complex calculations. Another point where VB loses to C++ is when it comes to strings, the larger they get the slower VB gets. The choise you make depends on what your capabilities are, that is, in VB wringting dlls is much easier because the VB compiler will take care of all the things behind the scenes, where in C++ you must do all the work.
That and the fact that VB is assumed to be easier than C++ are reasons to go for VB. So VB is fast creation, slower execution (in some cases that is).
If you absolutely need the best performance, and you know your way around in C++, this would be the obvious choise. So C++ is longer development times, better performance.

Once again, the answer to the question is: it depends

Tom Cannaerts
slisse@planetinternet.be

The best way to escape a problem, is to solve it.

kevin shen
March 20th, 2001, 08:57 PM
I have an algrism written by .c, I want to compile it to dll.

1)Which running speed could be faster, Use VB GUI or VC++ GUI to call this .c dll? Or almost the same use vb or vc++?
2)I want to compile .c to dll, do you have some good web site or book can introduce to me on how to do it?

Thank you!

Best Regards,

Kevin Shen

Cakkie
March 21st, 2001, 03:45 AM
To answer to the first question I could just say that the calling of a dll is almost the same in speed. Calling a C dll from VB would be the same as calling it from C. The first time you call the dll, VB will be a little slower than C because he probably has to load some C function (wich when calling from C are probably already in memory), from then on, the speed should be almost the same.

I don't know anything about compiling a C dll, but you could check out the C++ board, wich is also located on CodeGuru.

Goodluck

Tom Cannaerts
slisse@planetinternet.be

The best way to escape a problem, is to solve it.

kevin shen
March 21st, 2001, 01:47 PM
Do you think it's a good idea to use VB GUI to call .c dll and the running speed won't be hurt too much? VB GUI supposed to be better and easier to program compare with VC++, and many objects also fit well with VB. I can write complex calculation using c and compile it to .dll , then let VB call it.

Do you have some suggestion?

Thanks!

Best Regards,

Kevin Shen

gambit
March 26th, 2001, 03:16 AM
hi

have u meanaged to do it?
I have tried to include a VC dll into VB.
I try to do it using "add reference"
I have add it succesfully but is unbale to use it.
When i run it, i keep getting error messages.
Can give me some tips on how to do it?

thank you!

kevin shen
March 26th, 2001, 05:47 PM
I haven't managed to program yet. I checked MSDN. I found the topic "Declaring a DLL Procedure" maybe useful to us.
If you have some tips, please tell me.

Best Regards,

Kevin Shen

gambit
March 26th, 2001, 07:54 PM
hi

yup that work for most dll files.
But for one particular function in kernel32.dll "createfile" it does not work.
I do not understand why.

thanks anyway.

kevin shen
March 26th, 2001, 11:14 PM
Sorry...! I don't know, either. Maybe others can help?

Best Regards,

Kevin Shen