Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: g0dFraY on March 15, 2004, 06:47 PM

Title: DLL's
Post by: g0dFraY on March 15, 2004, 06:47 PM
Hi im new to these forums and fairly new to visual basic programming. i am interested in dll's, what they can be used for, how to use them, the extent they goto, and so on. If any one would post information that may help me understand them it would be greatly appreicated.
Title: Re:DLL's
Post by: Adron on March 16, 2004, 10:59 AM
A DLL is like an EXE except that the entry point is different and that it is typically loaded into the address space of another process.

A DLL typically exports functions that can be called.

In Visual Basic, you call exported functions from a DLL by using the "Declare" keyword to declare them and then calling them like any other function.

Some DLLs conform to some particular convention. One example is DLLs that export COM objects - they have a particular function that is called to create an object. This is the kind of DLL you as a VB programmer can create. It is complex and annoying to use from other languages.
Title: Re:DLL's
Post by: CrAz3D on March 18, 2004, 01:58 PM
What would an example of an entry point in a Visual Basic created DLL be?
IE: Code from the DLL that you would access from the App
Title: Re:DLL's
Post by: Adron on March 18, 2004, 02:00 PM
A method of a class.
Title: Re:DLL's
Post by: CrAz3D on March 18, 2004, 02:12 PM
DLL:

Public Function Run(ByVal Message as string)as string
   Run = message & "::"  & len(message)
end function


Main App:

private declare Run lib "Games.dll" (ByVal Message as string) as string

Run "Welcome to my DLL"

Correct?
Title: Re:DLL's
Post by: CrAz3D on March 18, 2004, 02:39 PM

Dim ObjS as object
set objs = CreateObject("Games.clsPlugIn")

msgbox objc.run(Username, message, GameName)

That works...
But is there any easier way to accessing the DLL other than registering it?
For it to work I have to regsvr32 PATH\Games.dll, other wise it will not work when the .DLL is not near it's Project & Class
Title: Re:DLL's
Post by: iago on March 18, 2004, 03:51 PM
Quote from: CrAz3D on March 18, 2004, 02:39 PM

Dim ObjS as object
set objs = CreateObject("Games.clsPlugIn")

msgbox objc.run(Username, message, GameName)

That works...
But is there any easier way to accessing the DLL other than registering it?
For it to work I have to regsvr32 PATH\Games.dll, other wise it will not work when the .DLL is not near it's Project & Class

There is some order that Windows looks for dll's.  First in the program's directory, then in %systemroot%, and maybe in some others, I don't know.
Title: Re:DLL's
Post by: g0dFraY on March 19, 2004, 05:42 AM
Thank you guys this has helped me understand what dlls are used for and how to use them. I havnt not yet started experimenting but will the minute i get home.

Thank you
Title: Re:DLL's
Post by: CrAz3D on March 19, 2004, 11:36 AM
Well I haven't been able to get the .DLL to register correctly, from my install file built with Inno.  Other people still cannot use it.  If you find a simple way to register it w/out doing regsvr32 talk to me.
Title: Re:DLL's
Post by: Adron on March 19, 2004, 11:42 AM
Quote from: CrAz3D on March 19, 2004, 11:36 AM
Well I haven't been able to get the .DLL to register correctly, from my install file built with Inno.  Other people still cannot use it.  If you find a simple way to register it w/out doing regsvr32 talk to me.

What's Inno? Does it have a checkbox to self-register a certain file after it's installed?
Title: Re:DLL's
Post by: CrAz3D on March 19, 2004, 01:58 PM
Well, it says it does, & from the debug/update window on the Install compiler of it it says that it is set to register the .DLL.  However, for some reason, it will not.

If anyone gets extremely bored & they decide to help me out & see if it registers the .DLL on their computer LINK (http://crazed.no-ip.com/files/setup.zip)

EDIT:
I do believe that it should work, I had the FileBox pointing to the incorrect place.  Still give it a try if you want to.
Title: Re:DLL's
Post by: g0dFraY on March 19, 2004, 05:36 PM
How would one obtain the functions from a dll? Are we resricted to few that have been discovered or may you search the dll or somewhat to obtain these. Also if you know of a function you want to use but do not know which dll it maybe in, is there a way to reveal it?

Thank you
Title: Re:DLL's
Post by: g0dFraY on March 19, 2004, 06:53 PM
I have jusr tried a test and i seem to be doing something wrong.

My DLL (compiled as test.dll)

Public Function msg(Message as string)
   msg = msgbox & message
end function


New project

Option Explicit
declare msg lib "test.dll" (Message as string)

Private Sub Form_Load()
msg "Well done, it is working correctly."
End Sub


i know i must be doing something wrong because it isnt working.
If you could point out what iv done wrong.
Thank you

Edit:
Figured it out, but it now gives me that it cant find test.dll, its placed on the desktop would one need to move it or register it, how would one register.
Title: Re:DLL's
Post by: o.OV on March 19, 2004, 07:17 PM
You are obviously a beginner trying to start off at a more advanced level then you should.
Title: Re:DLL's
Post by: Grok on March 19, 2004, 07:59 PM
Quote from: o.OV on March 19, 2004, 07:17 PM
You are obviously a beginner trying to start off at a more advanced level then you should.

I'll bet he learns a lot of things that might not make sense now, but will as he acquires more knowledge.  Reaching for things out of reach is how humans advance.  Our trips to space, to the moon, and Mars, generates many scientific advances and new knowledge.
Title: Re:DLL's
Post by: o.OV on March 19, 2004, 08:09 PM
Quote from: Grok on March 19, 2004, 07:59 PM
Quote from: o.OV on March 19, 2004, 07:17 PM
You are obviously a beginner trying to start off at a more advanced level then you should.

I'll bet he learns a lot of things that might not make sense now, but will as he acquires more knowledge.  Reaching for things out of reach is how humans advance.  Our trips to space, to the moon, and Mars, generates many scientific advances and new knowledge.

I'm not saying it is wrong to ask questions.
In my opinion. It would be easier to start off slow.
Read documentation on the stuff he wants to learn.
Save it hard disk and come back to it
when he feels he is ready to go at it again.
And if he still can't grasp it..
leave it and come back to it again when he has more "basic" knowledge.

This is how I learn.
Learning the basics first allows one to grasp new concepts.

In his case.
It seems to me he is trying to run before he can walk.
Title: Re:DLL's
Post by: g0dFraY on March 19, 2004, 09:01 PM
Yes i may be aiming to high but its what humans do. NASA didnt send humans to the moon so they could play, but to gain knowledge from the moon. I am do not want knowledge of DLL's so i can never use it but so i can gain more from that knowledge.
Title: Re:DLL's
Post by: CrAz3D on March 20, 2004, 12:46 AM
Quote from: g0dFraY on March 19, 2004, 06:53 PM
I have jusr tried a test and i seem to be doing something wrong.

My DLL (compiled as test.dll)

Public Function msg(Message as string)
   msg = msgbox & message
end function


New project

Option Explicit
declare msg lib "test.dll" (Message as string)

Private Sub Form_Load()
msg "Well done, it is working correctly."
End Sub


i know i must be doing something wrong because it isnt working.
If you could point out what iv done wrong.
Thank you

Edit:
Figured it out, but it now gives me that it cant find test.dll, its placed on the desktop would one need to move it or register it, how would one register.

You're on the right track.  Your .DLL is fine, it is how you ar trying to access it.

Dim obDLL as Object
    '//I have my object declared Publically in a module so I can use from other places
Set obDLL = CreateObject("PROJECT NAME.PROJECT CLASS")
    '//Inorder for your .DLL to work for others they must register the .DLL file on their computer (ie regsvr32)
msgbox obDLL.msg("Welcome to g0dFraY's DLLL")
    '//obDLL.RUN FUNCTION, you can run any Public function in your MAIN .DLL Project's Class