Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Interfacing C DLL with Fox.
Message
 
 
To
22/09/1998 13:48:03
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00139024
Message ID:
00139564
Views:
38
Alex,

If you want the DLL to work with a chunk of memory that VFP knows about VFP has to send an address of the buffer to the DLL. Your stack address that the DLL tried to send to VFP was outside the memory VFP can access thus protection violation.

declare integer TheDLL in mydll string @ cBuffer

cBuffer = space(30)
? TheDLL( &cBuffer )

int TheDLL( char * VFPBuffer )
{
strcpy( VFPBuffer, "Hi VFP" );
return strlen( VFPBuffer );
}

On my site is another article under Q&A, General that talks about structs and VFP.

>>If you need something, lemme know.
>
>I know the offer wasn't for me, but still... :-)
>
>Let me sound ridiculous for a little bit ok? You're all alowed to laugh a bit but you have to pay me a beer.
>
>Thanks to all of you, who gave me very nice pointers (so to speak <g>), I can finally make VFP chew the DLL. But that's for simple values...
>Let the fun begin:
>
>The C code:
>
>typedef struct tst_stru
>{
>  int iVal;
>} TST_STRU;
>
>TST_STRU getstru()
>{
>  TST_STRU local_struct;
>  local_struct.iVal = 154;
>  return (local_struct);
>}
>
>
>And the Fox code:
>
>Declare String getstru In DLLTest
>
>? getstru
>
>
>Now... This (why am I not surprised? ) crashes VFP. Why?
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform