calling unmanged code from j#
-
i have an unmanaged dll that exports a function that takes a TCHAR* parameter. i need to call this function from j#. in my j# file, i tried to set the marshal attribute like so, public static native void testStringFunction(/** @attribute MarshalAs(UnmanagedType.LPTStr)*/String s); when i call that function, my string is not marshaled to a TCHAR*. i tried all the different string types in the UnmanagedType enumeration. anyone have any ideas?? thanks.
-
i have an unmanaged dll that exports a function that takes a TCHAR* parameter. i need to call this function from j#. in my j# file, i tried to set the marshal attribute like so, public static native void testStringFunction(/** @attribute MarshalAs(UnmanagedType.LPTStr)*/String s); when i call that function, my string is not marshaled to a TCHAR*. i tried all the different string types in the UnmanagedType enumeration. anyone have any ideas?? thanks.
Did you attribute it with the
DllImportAttribute
, specifying the right native DLL? You should also specify in that attributeCharSet=CharSet.Auto
. Other than that, your code looks fine.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
-
Did you attribute it with the
DllImportAttribute
, specifying the right native DLL? You should also specify in that attributeCharSet=CharSet.Auto
. Other than that, your code looks fine.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----