Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calling C++ dll from C# - how to debug?
Message
 
To
20/10/2017 07:32:15
General information
Forum:
C#
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01655067
Message ID:
01656179
Views:
65
Whoa - I guess I never knew that. I wonder if that behavior was added later - I was pretty sure that didn't work or resulted in massive memory leaks. Checked briefly and sure enough it works without leaking. Thanks for pointing this out...

Regardless though, this will only work with methods that are properly exported with Win32API export rules. Any `raw` C/C++ functions won't just work and any API that follows Win32API rules *generally* uses OUT parameters to return values.

+++ Rick ---

>>You can't call a DLL function that returns a string because there's no way for FoxPro - at least not without an FLL in between - to capture the pointer that the function returns. CDecl calling convention generally doesn't work - you can only really call DLLs with WINAPI calling convention which has all APIs pretty much returning numeric values and any 'real' return values returned in passed in buffers.
>>
>>Your best bet is to wrap the function in a .NET DLL and call it with wwDotnetBridge or plain COM interop.
>
>Rick,
>
>Yes, you can call a dll that returns a string. Done it in the past
>It is my understanding that FoxPro allocs a string with the return value ( char*)
>
>
>Been looking for an example - https://msdn.microsoft.com/en-us/library/windows/desktop/ms647474(v=vs.85).aspx
>
>Now, how you declare and use it in C# - I don't know , tried with IntPtr but only the first char is returned (and converted to upper case)
>
>
>function CharUpperTest()
>	
>	declare string CharUpperA in user32.dll string s
>	
>	local x,s
>	s = 'abc'
>	
>	x = CharUpperA (m.s)
>	
>	&& assert false
>endfunc
>
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform