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.

Dark GDK / Question about dbCallDLL()

Author
Message
Guldan the Warlock
20
Years of Service
User Offline
Joined: 18th Feb 2004
Location: Azeroth
Posted: 8th Mar 2007 02:31
Hey guys,

So I just got done writing about 400+ lines of code, mostly wrapper functions for DLL calls, so I used dbCallDLL quite heavily. When I finished, I crossed my fingers and went to compile. The compiler then spit about 50 of these at me:

Quote: "
Error C2665: 'dbCallDLL' : none of the 11 overloads can convert parameter 2 from type 'const char [22]'
"


The number in the brackets varies, as I have different string lengths. Here's how I'm calling dbCallDLL:



Now I went and looked at the prototypes for the 11 said overloads, and every argument except for the dllId is a DWORD. So am I to understand that I'm going to have to typecast all the function names in my dbCallDLL calls to a DWORD? Or is there something I'm missing here?
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 8th Mar 2007 15:01 Edited at: 8th Mar 2007 18:44
Yes, you need to cast. No you aren't missing anything.

Actually, I've just had a thought ... don't start adding the casts until I get back. I might just have a solution.

[EDIT]One helper class and a shed-load of replacement functions later ... Yep, got a solution, as long as your arguments and return types are up to 4 bytes in size - anything more and this won't work.



If you pass doubles as arguments, they will be down-cast to floats. long long's will be down-cast to int's, or DWORD's if they are unsigned.

The code will automatically convert the returned value to the type that you specify. If you don't get it right then that's your fault.

One final point: Despite the number of lines involved and the fact that there's a class converting all of the values to/from DWORD's, the optimiser actually removes all trace of that code from the final executable when compiling in release mode ... no overhead!

If you haven't already done so, you might need to switch off the 'detect 64-bit portability issues' option, or live with the warnings it goves when converting char*'s to DWORD's.

Attachments

Login to view attachments
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 8th Mar 2007 19:55
Here's a slightly better version - the earlier one was not coded to allow any pointers apart from char*'s to be passed in. This one does.



The changes are to the class constructor to accept a void* instead of a char*, and to replace the char* conversion operator with a new templated conversion member function to pass back any pointer type.

Attachments

Login to view attachments
Guldan the Warlock
20
Years of Service
User Offline
Joined: 18th Feb 2004
Location: Azeroth
Posted: 10th Mar 2007 05:08
Thanks Ian. I'll add it in and let you know how it works.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th Mar 2007 19:29
If you have updated to the latest SDK (13/03/2007) then here's an updated version of the file that works ... it should work with both with a single change near the top, but I haven't tested on the older version.

Attachments

Login to view attachments
cypher0
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location:
Posted: 14th Mar 2007 01:30
I always assumed dbCallDLL was just for DBP
Why not just call the dll directly from whatever language you are using??!

Login to post a reply

Server time is: 2024-09-28 23:15:09
Your offset time is: 2024-09-28 23:15:09