|
-
Dec 20th, 2000, 03:38 AM
#1
Thread Starter
Addicted Member
Goodday everybody...
I would like to know how do i use DLL developed in VC++ in VB programs? What are the procedure i need to do to link it to my VB programs and how do i actually use the functions available in the DLL on my VB programs?
Your help will be most appreciated...
-
Dec 20th, 2000, 06:19 AM
#2
Frenzied Member
You should have declared the functions in the DLL for export and then you can use them in VB:
Code:
Private Declare Function FunctionName Lib "dllname.dll" (arguments as something) as something
'this is if the function in the dll returns a value else use
Private Declare Sub FunctionName Lib "dllname.dll" (arguments as something)
-
Dec 20th, 2000, 09:08 AM
#3
Lively Member
Do you know if you have to specify the path of the dll or not?
Does windows start looking for it in Windows\System or the application's directory?
Just curious.
Um americano que fala portugues.
-
Dec 20th, 2000, 09:44 PM
#4
New Member
Hi ttingen, if you dont specify the path, windows will look for the dll files based on the directories you've specified in the PATH ENVIRONMENT, and they usually check in the current folder first (the folder in which you store your VB project files).
If you do not put the dll in one of the directories specified in the PATH Environment, you may specify the path so that windows can locate the dll file directly.
Hope it helps.
-
Dec 20th, 2000, 09:52 PM
#5
Thread Starter
Addicted Member
thanks vlatko...
export the functions in th DLL? how do i do that?
hi misterkiasu...
where do i specify the PATH ENVIRONMENT?
-
Dec 21st, 2000, 06:07 AM
#6
Frenzied Member
If you put this in a C++ dll:
Code:
void _stdcall message(HWND hwnd)
{
MessageBox(hwnd,"text","Text",MB_OK);
}
and this in VB:
Code:
Private Declare Sub Message Lib "dllname.dll" (ByVal hwnd as Long)
'call it
Message Form1.hWnd
'pops up a message box
You can also use a def file and write the function names you want to export there
EXPORTS
Message
-
Dec 21st, 2000, 11:16 PM
#7
Thread Starter
Addicted Member
thanks vlatko...
but this can be used if the DLL is created as a Library-Type DLL, right?
what if i want to create an ActiveX DLL? can i create an ActiveX DLL in VC++ and how do i do it?
and also, this can bed use only if the function is a general function, right? what if i want to use a function which is in a class? how should i do it? In VB, how can i declare an object of the class created in the DLL?
correct me if i'm wrong...
-
Dec 22nd, 2000, 07:31 AM
#8
Monday Morning Lunatic
At the moment you can't use a C++ class from VB. All the virtuality semantics break down once you start copying things around .
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Dec 28th, 2000, 09:18 PM
#9
Thread Starter
Addicted Member
parksie...
what do you mean by "All the virtuality semantics break down once you start copying things around"?
can you please explain? thanks...
-
Dec 29th, 2000, 01:30 PM
#10
Monday Morning Lunatic
In C++, you have virtual inheritance. This means that a pointer to an object may not actually refer to that TYPE of object. It is usually used to great advantage in COM. What happens:
Code:
class Base {
public:
int Function() { return 5; }
};
class Derived: public Base {
int Function() { return 1; }
}
So, Derived is derived from Base. Normal sense indicates:
Code:
Base *pBase = new Base;
Derived *pDerived = new Derived;
pBase->Function(); // Returns 5
pDerived->Function(); // Returns 1
If you do THIS, though:
Code:
Base *pWhat = new Derived;
pWhat->Function(); // Returns 1
The magic of virtual inheritance is what causes the derived class' function to be called.
This is virtuality semantics.
In VB, you can't use a C++ class because there is no way to tell, even when reading vfptr, what function should be called.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|