[DllImport("A.DLL")]
public static extern int fun(参数1, 参数2);在用VC编写的这个A.DLL中
函数是int fun(LPCTSTR s1, LPCTSTR s2);
并且已经通过宏定义为Unicode请问在C#中如何声明与调用?public static extern int fun(string, string)?
public static extern int fun(cahr[], char[])?
好像都不好用啊
public static extern int fun(参数1, 参数2);在用VC编写的这个A.DLL中
函数是int fun(LPCTSTR s1, LPCTSTR s2);
并且已经通过宏定义为Unicode请问在C#中如何声明与调用?public static extern int fun(string, string)?
public static extern int fun(cahr[], char[])?
好像都不好用啊
public static extern int fun(string s1, string s1);1. C++定义为Unicode,那么LPCTSTR就等于LPCWSTR。所以要定义CharSet为Unicode。
2. LPCTSTR里面的C修饰为const,传入string就可以了。
但是我在dll里面打印传入的这个字符串
使用string和StringBuilder都打不出来啊
就是传递不进去值
不错。真细心,都没仔细看,你写的真仔细LPCTSTRLP:长指针,c语法中有段地址和虚拟地址之分,c++下都是虚拟地址了,但保留了LP
C :Const,不能修改内容
T :表明后面是TCHAR类型,虽然TCHAR不一定是UNICODE,这个要看是否定义了UNICODE宏,但大多数情况,还是表示unicode的。
STR:就是说是一个'\0'结尾的字符串你很细心的看到了C,T。赞。