|
-
Jul 27th, 2003, 01:31 PM
#1
Thread Starter
Frenzied Member
making a dll [resolved]
Hi
i want to be able to make a dll that i can use from another program to send a couple of values to and make it return some values. how do i do this?
i only know really basic c++ syntax...
Last edited by cyborg; Jul 27th, 2003 at 02:09 PM.
-
Jul 27th, 2003, 02:08 PM
#2
Thread Starter
Frenzied Member
-
Jul 27th, 2003, 02:13 PM
#3
main.cpp
Code:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
BOOL WINAPI DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID pReserved)
{
return TRUE;
}
int WINAPI MyAddFunction(int a, int b)
{
return a + b;
}
int WINAPI MyXorFunction(int a, int b)
{
return a ^ b;
}
project.def
Code:
LIBRARY "My Project"
EXPORTS
MyAddFunction @1
MyXorFunction @2
note that I declared all the functions as WINAPI (__stdcall). If you don't, they default to _cdecl and you probably wont be able to use them from Visual Basic, if that's what you're trying to do.
Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.
-
Aug 1st, 2003, 07:52 PM
#4
Hyperactive Member
Can you give me a way of doing it in plain C, without including the windows header file?
-
Aug 7th, 2003, 05:12 PM
#5
Addicted Member
just wondering...is the code you posted all it takes to write a *.dll that will run in vb?
i have a question for you...
Say you wanted to write a function that would read a file a line at a time and then return the lines as an array of strings to be read in a vb program how would you need to return the variables.
I guess my question is...How do you convert a C++ string which is just an array of characters into a vb string (i am guessing it is just an easier to use array of characters but i am not sure)
Thanks ahead of time!
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
|