Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / Making a DLL?

Author
Message
DB PROgrammer
17
Years of Service
User Offline
Joined: 9th Feb 2007
Location: Nowhere But Everywhere
Posted: 25th Sep 2007 23:07
Why doesnt this dll work?

dllmain.c


dll.h


untitled1.rc


DLL is attached.

I keep runing nowhere fast!

Attachments

Login to view attachments
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 26th Sep 2007 00:30
For some reason, I can't get a usable copy of your DLL to confirm what I think.

I'll tell you what I think anyway - you haven't defined BUILDING_DLL in your code, and not in your project settings either, so your DLLIMPORT is defined as __declspec(dllimport) instead of __declspec(dllexport) - you aren't exporting your functions.

If this is Visual C++, then that's all I can see wrong. If it isn't then the function name in your resource string may be incorrect too - the exported function names are different for different compilers.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
DB PROgrammer
17
Years of Service
User Offline
Joined: 9th Feb 2007
Location: Nowhere But Everywhere
Posted: 26th Sep 2007 04:32
I am using DevC++. I looked at how the help files said to get the decorated name but it only ever shows my function name never any stuff at the end like @@YAHXZ. I got that from a tutorial I was following I couldn't get it to work myself so I copyed and pasted everthing. But it still does not work.

Any Help!

I keep runing nowhere fast!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 26th Sep 2007 15:21
Remember where I said:
Quote: "the exported function names are different for different compilers"


Look in the DLL for your function name and put that plus any surrounding characters into your resource string.

If you can't find it, then you are not exporting it - it should look something like i8GetValue, although I may be completely wrong about that name.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
DB PROgrammer
17
Years of Service
User Offline
Joined: 9th Feb 2007
Location: Nowhere But Everywhere
Posted: 26th Sep 2007 19:48 Edited at: 26th Sep 2007 20:28
I figured it out all i had to do was make my .rc file look like this.



By the way I know its suposed to be all over the fourms but I spent a hour and I could not find it. How do you return a string?

EDIT:

Ok I think I found out how to return a string but I get a error when I try to build it.


With this code.

dllmain.cpp


dll.h


untitled1.rs


Please respond I need to learn this stuff.

I keep runing nowhere fast!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
DB PROgrammer
17
Years of Service
User Offline
Joined: 9th Feb 2007
Location: Nowhere But Everywhere
Posted: 26th Sep 2007 23:36
Using that code and .rs file I get this error.



What was wrong with the way I did it? Other then the error which seems alot like the error I got with your code.

I keep runing nowhere fast!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 27th Sep 2007 00:58
I haven't used Dev-C++ for literally years. All I can tell you is that's a project problem, not a source code problem.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
DB PROgrammer
17
Years of Service
User Offline
Joined: 9th Feb 2007
Location: Nowhere But Everywhere
Posted: 27th Sep 2007 02:53 Edited at: 27th Sep 2007 02:54
Ok I got it to compile with this code but in DBPro it has this error.



dllmain.cpp


dll.h


untitled1.rs


Please help!

I keep runing nowhere fast!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 27th Sep 2007 13:22 Edited at: 27th Sep 2007 13:27
"returnstring[%S%returnstring%"

BTW, where is 'string' defined? Where are you allocating the memory to hold it? How are you calling your function from DBPro?

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
DB PROgrammer
17
Years of Service
User Offline
Joined: 9th Feb 2007
Location: Nowhere But Everywhere
Posted: 27th Sep 2007 16:22
Its the way im trying to code it. I am "using namespace std;" what lets you use strings but thats not the right way to do it. I am leaving for two weeks when I come back I try doing it your way(the right way).

I keep runing nowhere fast!
hookah jake
17
Years of Service
User Offline
Joined: 5th Nov 2007
Location:
Posted: 5th Nov 2007 18:59
I can tell you one thing; you're not going to be able to return "my_string" as the class type "string." DB just won't take it. Furthermore, unless you actually plan on ever building this as anything but a DLL, I suggest you take out the "#if BUILDING_DLL" line.

Either way, you definitely need the DB pointer in there. For that you need to set up the DirectX SDK, dig out the globstruct.h header buried in ".\[Name of your DBPro folder]\Help\documents\Files\Third Party Commands\TESTCOMMANDS2\".

Finally, once you tweaked everything so your compiler will actually find the files pointed to by globstruct, toss this code into your header section:



If there is an easier way to set this up, I'd love to hear it. As for your string return code, it should look something like this:



I'll be mildly amazed if someone can get this to work just by reading a forum tutorial. DBPro does not like receiving strings at all.

<i><sub>If we end up having to choose a national language, I'm voting for LISP.</sub></i>

Login to post a reply

Server time is: 2024-11-22 22:43:08
Your offset time is: 2024-11-22 22:43:08