-1
我想创建句柄到Windows Phone设备。但是CreateFileW
返回-1,错误代码是3 ERROR_PATH_NOT_FOUND
。对这个问题的任何帮助?CreateFileW()句柄返回-1
我的代码:
handle = CreateFileW("\\\\.\\NOKIA_TOUCH", GENERIC_READ Or GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, IntPtr.Zero, 3, 0, IntPtr.Zero)
If handle = -1 Then
ShowMsg(Marshal.GetLastWin32Error)
Else
ShowMsg("Success!")
End If
编辑:P/Invoke的代码:
<DllImport("kernelBase.dll", CharSet:=CharSet.Unicode, ExactSpelling:=False, PreserveSig:=True, SetLastError:=True)>
Public Shared Function CreateFileW(ByVal lpFileName As String, ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, ByVal lpSecurityAttributes As IntPtr, ByVal dwCreationDisposition As Integer, ByVal dwFLagsAndAttributes As Integer, ByVal hTemplateFile As IntPtr) As IntPtr
End Function
你可以[编辑]这个并向我们展示p/Invoke的代码吗? – theB
这是C语法,你不要在Basic中逃避反斜杠。使用'“\\。\ NOKIA_TOUCH”' –
谢谢@ hans-passant,但是现在错误代码是2.'ERROR_FILE_NOT_FOUND' – Clocker