|
-
Sep 27th, 2000, 07:32 PM
#1
Thread Starter
Junior Member
Hi,
I've been trying to creating a simple (like adding two numbers or concatenating two strings) dll to use in VB.
Of course, I try to do the most amount of stuff with the least amount of knowledge ;-) So _detailed_ step-by-step instructions would be nice.
So far I've managed to...
- create a project (in Borland 5.02 not VC)
- make the target a .dll file
- add a .cpp and .h file with one function
- add a .def file with the text
EXPORTS
FunctionName
Tried to make the dll got an error like ...unresolved reference from the root... or something like that.
I bet I'm going about this all wrong so any advice/actual source code would be appreciated.
Amanda
-
Sep 29th, 2000, 05:12 PM
#2
Monday Morning Lunatic
Could you post your code? I'll take a look at it for you.
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
-
Oct 1st, 2000, 01:11 AM
#3
Thread Starter
Junior Member
Hi again,
I read a couple of replies on this board and realized I was missing the crucial "__declspec(dllexport)" bit.
When I added this to the function, I was able to create a dll that worked in VB.
Yet when I compiled the dll I got a message that said "Failure" and in the message window (in Borland) it said
"Info :Transferring to C:\PROGRAM FILES\BC5\BIN\implib.exe @c:\windows\TEMP\RSP0.$$$"
I don't know enough to know what this means, and I find it strange that despite a "Failure" message, that the dll seems to work fine.
Any insight would be appeciated,
Amanda
P.S. Here's my code
vb_prac.cpp
-----------
extern "C" __declspec(dllexport) int _stdcall MyAdd(int a, int b)
{
return a + b;
}
vb_prac.def
-----------
EXPORTS
MyAdd
-
Oct 1st, 2000, 04:28 AM
#4
Monday Morning Lunatic
I can't see why that would make a difference, since __declspec(dllexport) is designed as a replacement for the .def file.
If you omit the .def file from your compilation, it should still work.
(Since I don't have BC I can't give any help on the "Failure" message...)
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
|