我想用vb.net写的程序来取得串口的句柄,但是getlasterror总是得到12的值,查MSDN,注明为The access code is invalid。请各位高手给予指点程序哪儿有问题还是我createfile的参数值有问题:
Dim hDiskName As Integer
Dim tFile As StreamWriter
Dim tmpString As String
If hDiskName.Equals(INVALID_HANDLE_VALUE) Then
tmpString = diskName + "--Get invalid handle. GetLastError is " + GetLastError().ToString
Else
tmpString = diskName + "--" + hDiskName.ToString
End If
If File.Exists(tempPath) = False Then
tFile = File.CreateText(tempPath)
Else
tFile = File.AppendText(tempPath)
End If
tFile.WriteLine(tmpString)
tFile.Flush()
tFile.Close()