以前在9.0里做里用API做的读称好好的,但升到12.5后读的全是乱码,下面是我的API定义,请指教
//取串口读数
Function Boolean CloseHandle(ulong hObject ) Library "kernel32.dll"
FUNCTION boolean ReadFile(ulong fhand, ref string lpbuffer,ulong numbyte, ref ulong bytesread, ulong lpover) LIBRARY
"kernel32.dll" alias for "ReadFile;Ansi"
FUNCTION ulong CreateFileA(ref string fname, ulong f_access, ulong f_share, ulong f_sec, ulong f_create, ulong f_flag,
ulong f_attrib) LIBRARY "kernel32.dll" alias for "CreateFileA;Ansi"
Function Boolean WriteFile(uLong handle,ref string lpbuffer, ulong numbytes, ref ulong bytesread, ulong lpOverLaped)
Library "Kernel32.dll" alias for "WriteFile;Ansi"
Function Boolean GetCommProperties(ulong hFile,ref COMMPROP lpCommProp ) Library "Kernel32.dll" alias for
"GetCommProperties;Ansi"
Function Boolean BuildCommDCBA(ref string lpDef,ref DCB lpDCB ) Library "Kernel32.dll" alias for "BuildCommDCBA;Ansi"
Function Boolean SetCommState(ulong hCommDev,ref DCB lpdcb ) Library "Kernel32.dll" alias for "SetCommState;Ansi"
Function Boolean GetCommState(ulong hCommDev,ref DCB lpdcb ) Library "Kernel32.dll" alias for "GetCommState;Ansi"
Function ulong GetLastError() Library "Kernel32.dll"
Function Boolean SetCommTimeouts(ulong hCommDev,ref COMMTIMEOUTS lpctmo ) Library "Kernel32.dll" alias for
"SetCommTimeouts;Ansi"
Function Boolean PurgeComm(ulong hCommDev, ulong fdwAction ) Library "Kernel32.dll"
------解决方案--------------------
试试 这个
http://download.csdn.net/detail/pcwe2002/5364269
------解决方案--------------------
直接用mscomm控制来实现,比较方便
------解决方案--------------------
可以参考
http://blog.sina.com.cn/s/blog_6e0ce6ff0100vvmz.html