Hi all,
I'm programming a C# application which invokes a DLL (written in standard
C).
I have tried many things but any success since the beginning of the weeks.
Here is the C prototype:
unsigned short GetField ( unsigned short fieldId, char* fieldValue, size_t*
FieldSize);
This method should return a value in fieldValue.
Here is my DLLImport:
[DllImport("reader20.dll", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi)]
private static extern ushort GetField (
ushort fieldId,
StringBuilder fieldValue,
out int TailleMax
);
Here is my call:
int s;
StringBuilder value = new StringBuilder();
SGD_LireChamp(123, value, out s);
I don't understand why "value" still remain to empty string.
Is there something wrong in my code? Do you have any alternative?
Hope someone can help me.
Thanks
Franck
NB:
This DLL can not be modified because it is shipped by a provider.
Mattias Sjögren - 12 Jul 2006 22:59 GMT
>I don't understand why "value" still remain to empty string.
>
>Is there something wrong in my code? Do you have any alternative?
Does the function return text or binary data? Do you have any
existing, working code calling the function you can post that we can
compare with?
Mattias

Signature
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Fx - 26 Jul 2006 13:42 GMT
Hi,
I've found !
Just replace "private" attribute by "public" and parameters are correctly
handled by P/Invoke.
> Hi all,
> I'm programming a C# application which invokes a DLL (written in standard
[quoted text clipped - 33 lines]
> NB:
> This DLL can not be modified because it is shipped by a provider.