-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