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...
Printable View
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...
nm...found the answer
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.
Can you give me a way of doing it in plain C, without including the windows header file?
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!