我的源码如下:using System;
using System.Runtime.InteropServices; namespace JustinIO
{ public class CommPort
{ //.......... [sysimport(dll = "kernel32.dll")] private static extern bool GetCommState( int hFile, // handle to communications device ref DCB lpDCB // device-control block ); 以上不能编译通过,提示错误如下:
不能找到类型或命名空间名称"sysimport"
using System.Runtime.InteropServices; namespace JustinIO
{ public class CommPort
{ //.......... [sysimport(dll = "kernel32.dll")] private static extern bool GetCommState( int hFile, // handle to communications device ref DCB lpDCB // device-control block ); 以上不能编译通过,提示错误如下:
不能找到类型或命名空间名称"sysimport"
private static extern int CreateCompatibleDC(int hDC);用API么?按上写法吧~
改为:
[DllImport("kernel32.dll")]
C#中是这样用的.