Valhalla Legends Forums Archive | Visual Basic Programming | DLL's

AuthorMessageTime
g0dFraY
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.
March 16, 2004, 12:47 AM
Adron
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.
March 16, 2004, 4:59 PM
CrAz3D
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
March 18, 2004, 7:58 PM
Adron
A method of a class.
March 18, 2004, 8:00 PM
CrAz3D
DLL:
[code]
Public Function Run(ByVal Message as string)as string
Run = message & "::" & len(message)
end function
[/code]

Main App:
[code]
private declare Run lib "Games.dll" (ByVal Message as string) as string

Run "Welcome to my DLL"
[/code]
Correct?
March 18, 2004, 8:12 PM
CrAz3D
[code]
Dim ObjS as object
set objs = CreateObject("Games.clsPlugIn")

msgbox objc.run(Username, message, GameName)
[/code]
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
March 18, 2004, 8:39 PM
iago
[quote author=CrAz3D link=board=31;threadid=5803;start=0#msg50279 date=1079642395]
[code]
Dim ObjS as object
set objs = CreateObject("Games.clsPlugIn")

msgbox objc.run(Username, message, GameName)
[/code]
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
[/quote]

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.
March 18, 2004, 9:51 PM
g0dFraY
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
March 19, 2004, 11:42 AM
CrAz3D
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.
March 19, 2004, 5:36 PM
Adron
[quote author=CrAz3D link=board=31;threadid=5803;start=0#msg50430 date=1079717776]
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.
[/quote]

What's Inno? Does it have a checkbox to self-register a certain file after it's installed?
March 19, 2004, 5:42 PM
CrAz3D
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

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.
March 19, 2004, 7:58 PM
g0dFraY
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
March 19, 2004, 11:36 PM
g0dFraY
I have jusr tried a test and i seem to be doing something wrong.

My DLL (compiled as test.dll)
[code]
Public Function msg(Message as string)
msg = msgbox & message
end function
[/code]

New project
[code]
Option Explicit
declare msg lib "test.dll" (Message as string)

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

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.
March 20, 2004, 12:53 AM
o.OV
You are obviously a beginner trying to start off at a more advanced level then you should.
March 20, 2004, 1:17 AM
Grok
[quote author=o.OV link=board=31;threadid=5803;start=0#msg50520 date=1079745443]
You are obviously a beginner trying to start off at a more advanced level then you should.
[/quote]

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.
March 20, 2004, 1:59 AM
o.OV
[quote author=Grok link=board=31;threadid=5803;start=0#msg50527 date=1079747943]
[quote author=o.OV link=board=31;threadid=5803;start=0#msg50520 date=1079745443]
You are obviously a beginner trying to start off at a more advanced level then you should.
[/quote]

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.
[/quote]

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.
March 20, 2004, 2:09 AM
g0dFraY
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.
March 20, 2004, 3:01 AM
CrAz3D
[quote author=g0dFraY link=board=31;threadid=5803;start=0#msg50518 date=1079743987]
I have jusr tried a test and i seem to be doing something wrong.

My DLL (compiled as test.dll)
[code]
Public Function msg(Message as string)
msg = msgbox & message
end function
[/code]

New project
[code]
Option Explicit
declare msg lib "test.dll" (Message as string)

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

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.
[/quote]

You're on the right track. Your .DLL is fine, it is how you ar trying to access it.
[code]
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
[/code]
March 20, 2004, 6:46 AM

Search