Anil Kumar
Anil Kumar

Reputation: 493

How to deal with double pointers in VFP for calling c based DLL

How to deal with double pointers in VFP for calling c based DLL

I have a c language DLL which has parameters of double pointer as given below

int fun_foo(char *str1,char **str2)  //str2 has some info. when returns from function

In FoxPro I am trying to call this function from its DLL. How can I can call this; I tried as :

DECLARE INT fun_foo IN sample.dll STRING,STRING @

I found that char* can be passed with string parameter but i have difficulty with double pointer string@ is not working. Can anyone give clue how to pass parameter in Visual foxpro for a double pointer param in c function(DLL)

the data i get from the function in this double pointer is important for me

I am using Visual FoxPro 9.0 SP1 and DLL is of 32 bit made on visual c++ 2005

Thanks in Advance

Upvotes: 1

Views: 1678

Answers (2)

Carlos Alloatti
Carlos Alloatti

Reputation: 313

Short answer:

Use vfp2c32.fll

http://vfpx.codeplex.com/releases/view/71594

From the help file:

ReadPointer Retrieves a pointer from the specified address.

Long answer:

If you want to do it only with VFP, check SYS(2600), BINTOC, CTOBIN and strncpy (that last one is in the c runtime that you need anyway to run VFP executables.)

DECLARE INTEGER fun_foo IN sample.dll ;
STRING str1,;
INTEGER @pointer

m.str1 = "sometext"
m.pointer = 0

m.result = fun_foo(m.str2, @m.pointer)

Now what is in that pointer? you don't say. A NUL terminated string? use strncpy. An INT or some fixed length string? Use sys(2600)

Upvotes: 1

LAK
LAK

Reputation: 970

I don't know that it can be done from Foxpro itself, but maybe you could (if you're proficient in C) create an intermediate ActiveX object or the like in C, which dereferences your double pointer, and returns it to VFP?

Upvotes: 0

Related Questions