|
-
Apr 27th, 2000, 12:29 AM
#1
Thread Starter
Frenzied Member
Yes.
I have absolutley no Idea where to go from there, I learnt C++ from the complete Idiots guide to C++ and I only know how to do console mode apps, but I know enough about the API to do everything I need in the functions, I've tested the functions from a bit of a consolemode front end and they work (as far as I can tell, I didn't bother putting the graphics out to the screen)
I need it as a dll as I pass out pointers an use callback functions can I pass out pointers in a staticly linked app (obviously I can but can I get at the memory).
-
Apr 27th, 2000, 01:07 AM
#2
Lively Member
if you're using VC then you'd use the wizard to make a dll.. in order to get at the functions in your dll, you have to export them. Here's some info on that...
MFC DLL -
http://msdn.microsoft.com/library/de...an_mfc_dll.htm
C DLL -
http://msdn.microsoft.com/library/of...ce97/SF7E6.htm
You'd refrence them in VB the same way you refrence any other DLL call. like...
<from VB5 help>
Declare Sub MessageBeep Lib "User32" (ByVal N As Long)
you're saying that MessageBeep is in lib user32 and it's expecting a long.
Hope that helps..
-
Apr 27th, 2000, 02:43 AM
#3
Thread Starter
Frenzied Member
Ok I'm still having trouble, I start up the appwizard and select win32dll, and use a simple DLL, I type my function in like the website said so It looks like this
Code:
_declspec(dllexport) long _cdecl myfunc(short factor1,short factor2)
{
return (long)(factor1 * factor2);
}
into the main cpp file and batchbuild so I get a release version.
I declare it in VB and it can't find the file unless I give it the full file extension, when I do this it says that it can't find DLL entry point myfunc.
What do I do? This is really frustrating.
-
Apr 28th, 2000, 10:15 AM
#4
Lively Member
how did you declare it in your vb app?
-
Apr 28th, 2000, 07:46 PM
#5
Thread Starter
Frenzied Member
I'm declaring it as I would an API
Code:
Private Declare Function myfunc Lib "C:\TestDll\Release\TestDll" (factor1 As Integer, Factor2 As Integer) As Long
I've tried loads of other ways of doing it (C++ side) as well, every source in MSDN does it differently and they all give me the same error.
-
Apr 30th, 2000, 09:10 PM
#6
Lively Member
I think you're missing the actual "EXPORT" part. It does get a little confusing. Here's another article that may help.. though it's more in-depth and may confuse you even more..
http://msdn.microsoft.com/library/de...plications.htm
let me know how you make out.
-
Apr 30th, 2000, 09:23 PM
#7
Thread Starter
Frenzied Member
Thanks, I think I've seen that but I'll have another look, I think MSDN is just designed to confuse people.
-
May 1st, 2000, 02:19 AM
#8
It maybe a type but you are missing an underscore on the __declspec
_declspec(dllexport) long _cdecl myfunc(short factor1,short factor2)
{
return (long)(factor1 * factor2);
}
then depending on what you do inside your function you may have to do:
extern "C"
{
__declspec(...)...
}
and did you do the BOOL WINAPI DllMain?
-
May 1st, 2000, 03:06 AM
#9
/*
OK i should have read all of the messages, here is what you do, paste this into a .cpp and compile:
*/
#include<iostream.h>
/*
this is where you enter the dll,
you must have it, and it won't work without it
that's where you get the error message
*/
BOOL WINAPI DllMain(HANDLE HModule, DWORRD ul_reason_for_call, LPVOID lpReserved)
{
switch(ul_reson_for_call)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_PRECESS_DETACH:
break;
}
return(TRUE);
/*depending on functions you use*/
extern "C"
{
extern __declspec( dllexport) long myFunctionName(myParameters);
}
long myFunctionName(myParameters)
{
return(10);
}
[Edited by Faust on 05-01-2000 at 04:08 PM]
-
May 1st, 2000, 05:52 AM
#10
Thread Starter
Frenzied Member
/*depending on functions you use*/
extern "C"
{
extern __declspec( dllexport) long myFunctionName(myParameters);
}
I missed out that bit, I wish MSDN was good, it should have made it clearer.
I'm assuming this is a bit like the way you declare functions in classes, and that you can overload them and the like, I makes much more sense now thanks.
If it wasn't for this sentence I wouldn't have a signature at all.
-
May 1st, 2000, 06:05 AM
#11
Hyperactive Member
Sam,
MSDN Article Q194609 may be of some help to you. It's available at http://msdn.microsoft.com/default.asp (use search on Q194609). Hope it helps.
-
May 2nd, 2000, 09:27 PM
#12
Thread Starter
Frenzied Member
OK, I've just about got the hang of it, Thanks a lot for your help.
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
|