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 / TPC and updating passed parameters...

Author
Message
drdoo
18
Years of Service
User Offline
Joined: 24th Jan 2006
Location:
Posted: 21st Mar 2007 07:13
Hi all, I've just created a prototype TPC Dll for DBPro and all is working fine. However, I cannot work out how to update/modify the parameters passed to a TPC Dll.....example:

(I used Delphi and thanx to empty user for tutorial on this )

Suppose I have a procedure which just increments three values passed from DBPro to the TPC DLL:

procedure TestProc(a,b,c: LongInt)
begin
inc(a);
inc(b);
inc(c);
end;

Now when this procedure is called from DBPro like so:
a = 1 : b = 1 : c = 1
TestProc(a,b,c)
print a;b;c

it is called fine...except the passed parameters are not changed when the call returns back to DBPro. (should print 222) ???

I understand the stringtable and all is fine in that department as I have a fully working DLL for the functions that return a single value. Only I cannot getting any procedures to work that pass variable parameters (by ref)......help please...

Delphi TPC code here:

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 21st Mar 2007 20:57
You can only change one of the input parameters, and if you do this, you will not be able to return any other value.

In the string table, in the section for the letters to specify the parameter types, put a star * after the parameter you want to change. The return value of your function will automatically be placed in this variable.

This is because your a,b,c variables are only copies of the DBPro ABC variables, and will be automatically cleared when your function ends.

The return type of your function needs to be the relevent type for the starred parameter.

Check my thread here

drdoo
18
Years of Service
User Offline
Joined: 24th Jan 2006
Location:
Posted: 22nd Mar 2007 02:02
thnx diggsey, I read your post shorty after posting but wan't sure what the * really did. So TPC's can only return 1 parameter as a ref variable I'll try what you said.

I do have the GlobStruct headers and noticed this:



Is it possible to modify DB Global variables using this procedure from within the TPC Plugin ???

I got to admit that the TPC interface is very very confusing and not much info is available in the docs. I've gathered most of the info from the forums which is mosty out of date.
TinTin
18
Years of Service
User Offline
Joined: 16th May 2006
Location: BORG Drone Ship - Being Assimilated near Roda Beta (28)
Posted: 23rd Mar 2007 01:16
This would be great if DBP supported it, but sadly it don't...

MyDll.dll C++ UDT Function Parameter..



The DBP Calling code..



I live and hope that somedat DBP will suport this type of functionality.... (guy's )

Cyberspace was becoming overcrowded and slummy so I decided to move. These nice chaps gave me a lift.
drdoo
18
Years of Service
User Offline
Joined: 24th Jan 2006
Location:
Posted: 23rd Mar 2007 02:57
There is a way to pass custom structure types but it involves using Memory Mapped Files (MMF). You would of course have to load the MMF functions via Win32 API calls within DBP.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Mar 2007 15:16
You don't need to memory mapping at all unless you are getting results from another process.

Here's how to do it:
Change your function to accept a memory address, and to write its results to that.

In DBPro, create a memblock and get its address. Then call your function with this address. Then after you've called the function, you can use DBPro to read the results back and put them into variables.

It ain't neat, but it works

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 23rd Mar 2007 19:19
Make memory also works similarly

drdoo
18
Years of Service
User Offline
Joined: 24th Jan 2006
Location:
Posted: 23rd Mar 2007 20:03
thanx, IanM.

so you say it's possible to pass a pointer from DBPro and access the pointer memory from within the DLL.....ok, I will give it a try tonight

Login to post a reply

Server time is: 2024-11-22 17:04:25
Your offset time is: 2024-11-22 17:04:25