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.

Programming Talk / C++ / C# - Getting a string from a DLL with dbpro

Author
Message
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 2nd Jun 2005 12:08
I've been trying for a while to do this, but it just refuses to work properly for me. What I am doing is trying to pass a value to a function, and return a string from the function.

I have constructed the simplest test, and it is doing something I really don't understand. Its returning the string, but the value I pass it is coming out really wierd. Here is the C++ file:



Here is the resource file to compile in the dll:



And here is the code I am using in DBP:



I am compiling using DevC++ (Mingw?). When I create the dll, copy it to the plugins-user folder, and run that dbp code, the it outputs a file containing the text 'value: 0'.

Anyone know what could be wrong?


"Lets migrate like bricks" - Me
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Jun 2005 21:36
Yes - you don't do string handling like that with DBPro. You need to use the CreateDeleteString function, which means you need the core pointer too.



I've not fully tested this, but it should be fine.
Also, because this function is returnnig a string, it should remove the string it is replacing (my code does this, yours doesn't). Even though it has an extra parameter your resource string should stay exactly as you now have it

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins and source code http://www.matrix1.demon.co.uk
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 3rd Jun 2005 00:27
I didn't realise not doing that would result in such odd... results.

Thanks for the help Ian!


"Lets migrate like bricks" - Me
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 3rd Jun 2005 08:03
All of the rules that are in the plug-in help document apply equally to Dev-C++ plug-ins. It's just a little harder to get hold of the core pointer.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins and source code http://www.matrix1.demon.co.uk
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 3rd Jun 2005 09:38
My plan was to eventually do it like that, but I was just doing some testing, and I had no idea such things could happen (never really done this before). Also what confused me was that it worked fine when it wasn't a proper TPC.

I noticed sometimes I would get a really big number written to that file. Would that be the pointer to the old string that I saw?


"Lets migrate like bricks" - Me
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 3rd Jun 2005 21:51
Quote: "it worked fine when it wasn't a proper TPC"


That's because the CALL DLL mechanism and the PTC mechanism are different. What you were doing will work perfectly fine if you stay with the CALL DLL method.

Quote: "Would that be the pointer to the old string that I saw?"

Yes.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins and source code http://www.matrix1.demon.co.uk
Three Score
19
Years of Service
User Offline
Joined: 18th Jun 2004
Location: behind you
Posted: 6th Jun 2005 05:56
if u are making a tpc only for u and not really plannign to give it out then i would just stay with call dll but since he gave u that code i doubt u will and will go for ther convience

formerly shadows of emptiness

Login to post a reply

Server time is: 2024-05-07 13:13:37
Your offset time is: 2024-05-07 13:13:37