[DllImport("kernel32.dll", SetLastError = false, CharSet = CharSet.Auto)]
private static extern IntPtr CreateFile(string fileName, uint desiredAccess, uint shareMode, uint securityAttributes, uint creationDisposition, uint flagsAndAttributes, uint templateFile);
device = CreateFile(deviceList[i],
DESIREDACCESS.GENERIC_READ | DESIREDACCESS.GENERIC_WRITE,
SHAREMODE.FILE_SHARE_READ | SHAREMODE.FILE_SHARE_WRITE,
0,
CREATIONDISPOSITION.OPEN_EXISTING,
FLAGSANDATTRIBUTES.FILE_FLAG_OVERLAPPED,
0);
int errCode = Marshal.GetLastWin32Error();
//errCode 返回0,device 返回0xffffffff
errCode 返回0,device 返回0xffffffff
######有什么解决的办法吗?
好好的你为什么要调用API去创建文件,c#自己有创建文件的方法呀