PDA

View Full Version : DLL information



sandyrepope
28-04-2008, 03:10
Is it hard to write a DLL?

Do they have any special requirements?

I'd appreciate any information I can get about DLLs.

Thanks
Sandy

Petr Schreiber
28-04-2008, 16:49
Hi Sandy,

which tools do you consider for DLL creation?
There is usually nothing difficult as DLL is just package of functions.
Usually you just put in the source functions you want, add their export names and that is all.

So far the easiest way to do DLL seemed the way it is done in PowerBASIC and Delphi 6/7.

Do you mean "classic" DLL or thinBASIC module DLL ?


Bye,
Petr

sandyrepope
29-04-2008, 00:24
which tools do you consider for DLL creation?

Not sure what this means. Do you mean like using Emergence compiler?


Usually you just put in the source functions you want, add their export names and that is all.

Export names???


So far the easiest way to do DLL seemed the way it is done in PowerBASIC and Delphi 6/7.

Is there a dll tutorial in PowerBASIC?


Do you mean "classic" DLL or thinBASIC module DLL ?

thinbasic module dll. (I don't know what "classic" DLL is.)

Thanks
Sandy

ErosOlmi
29-04-2008, 01:07
Ok, where to start from ...

maybe from DLL definition

Imagine a DLL as a box that contains precompiled functions. All API functions are defined inside DLLs
All functions available to the external of the DLL are called "exported" because their names are visible from the outside of the DLL.
Unfortunately the only thing you can see is the name of the exported functions and not the parameters that functions need.

A utility I found indispensable to understand DLLs and what they export is Dependancy Walker:
"Dependency Walker is a free utility that scans any 32-bit or 64-bit Windows module (exe, dll, ocx, sys, etc.) and builds a hierarchical tree diagram of all dependent modules. For each module found, it lists all the functions that are exported by that module, and which of those functions are actually being called by other modules."
Download from: http://www.dependencywalker.com/
Download it and put into a new folder. Than execute it and open any DLL (or EXE) your want to check.

How to create a DLLs?
You need a real compiler to create a DLL. Personally I would go with the following one (this is just a personal taste):

1st: Power Basic. It is my preferred language and its syntax is very close to thinBasic (well, thinBasic is very close to Power Basic, it is the king)
2nd: I would go with FreeBasic. Mainly because it has the full range of data types from single bit to dynamic strings. We also used it to create thinBasic modules so we can help you on this
3rd: any C compiler. If you know C you can go everywhere

Depending on the compiler, we can go on discussing it. I'm sorry I do not know EBasic and I cannot help on this.

Classic DLLs or thinBasic modules?
Once you will have a more precise idea on what is a DLLs, we can give a go with thinBasic modules.
But just to give you a quick overview:

a thinBasic module in nothing more than a standard DLLs but with some imposed thinBasic rules.
a thinBasic module MUST always export a function called "LoadLocalSymbols"
can optionally export a function called "UnLoadLocalSymbols"
must link back thinCore.dll
must use standard calling convention in function declaration
...

Remember that:

thinBasic can use thinBasic module (of course ;) ) just adding the clause "USES (http://www.thinbasic.com/public/products/thinBasic/help/html/index.html?uses.htm) ..." followed by the module name. This because the special rules I mentioned before let thinBasic Core engine and thinBasic module talk each other
thinBasic can use external DLLs using the DECLARE (http://www.thinbasic.com/public/products/thinBasic/help/html/index.html?declare.htm) statement just declaring the function names, the DLL names and the parameters sequence and type. thinBasic also simplify external DLLs usage because it is able to find them in a predetermined order.


Power Basic tutorial to create a DLL
Just recently Power Basic put online their compiler help. You can find it at: http://www.powerbasic.com/support/help/pbwin/index.htm
In particular have a look at http://www.powerbasic.com/support/help/pbwin/html/What_is_a_Dll_.htm
It gives some info on how to create a DLL in Power Basic

FreeBasic
Download FreeBasic compiler from http://www.freebasic.net/index.php/download
From the same url, download CHM documenation and search inside it for topic "Shared Libraries". It will show what is a DLL and how to create it.

_________________________________________________
Hope this can help as starting point.
Eros

Petr Schreiber
29-04-2008, 08:51
Hi Sandy,

just one think to add after Eros complete explanation :) - if you want to compare the way module DLLs are done in different languages, just have look at thinBASIC\SDK, and unzip SDK.zip.

You will find there samples how to create module in FreeBASIC, PowerBASIC,IBasic, various C compilers and MASM.


Petr

sandyrepope
29-04-2008, 14:31
Thank you for the replies. They give me a good start toward understanding DLL.

Thanks
Sandy

kryton9
29-04-2008, 22:00
Sandy you will need to use a language that can make a dll, which language are you thinking about?

sandyrepope
29-04-2008, 23:07
Sandy you will need to use a language that can make a dll, which language are you thinking about?

Emergence basic. (Ebasic)

Sandy

kryton9
30-04-2008, 00:54
I made an SDK for ebasic, basically a very slightly modified version of the ibasicpro SDK.

I can help you make a dll or even make a video tutorial if you want on how to make one... give me a couple of days, I need to setup the video capture app and practice with ebasic a bit as haven't really done anything with it for awhile.

sandyrepope
30-04-2008, 02:59
I appreciate the offer of help. Right now I have a lot to read and study so I'm not ready to start trying to write a dll yet but when I am ready I'll be asking for help.

Thanks
Sandy