LPCTSTR 转换到C# 参考下面 API
HWND FindWindow(
LPCTSTR lpClassName,
LPCTSTR lpWindowName
);
The corresponding Prototype in C# will be
[DllImport("user32.dll",EntryPoint="FindWindow",CharSet=CharSet.UNICODE)]
Public static extern int MyFindWindow(string _WindowClassName, string _WindowName);
参考文章
http://weblogs.asp.net/rmahato/archive/2003/12/29/46335.aspx
借个地问下
PB声明
Function Integer DC_Mif_Read(Integer bAddr ,Ref String bData ) Library "Fox_DC.dll"
我在C#中调用
[DllImport("FOX_DC.dll", EntryPoint = "DC_Mif_Read")]
public static extern int DC_Mif_Read(UInt16 bAddr,ref string bData);
string udd = "";
DC_Mif_Read(0, ref udd);到这句就出错了
引发类型为“System.ExecutionEngineException”的异常。
高手帮忙
LPCTSTR 是字符串指针类型 需要用String,楼主的写法有问题;
[DllImport("..\\Scan.dll")]
public static extern HINSTANCE InitTwainDLL(ref String szDLLName);
或者
String str = Marshal.PtrToStringAuto(指针地址);