2015-11-01 119 views
-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 
+0

你可以[编辑]这个并向我们展示p/Invoke的代码吗? – theB

+1

这是C语法,你不要在Basic中逃避反斜杠。使用'“\\。\ NOKIA_TOUCH”' –

+0

谢谢@ hans-passant,但是现在错误代码是2.'ERROR_FILE_NOT_FOUND' – Clocker

回答

0

这是不太可能的工作(你可能不具备安全能力去跟司机诺基亚),即使它在您的设备上进行调试时仍能正常工作,您将无法将其提交给Windows应用商店(除非您需要使用此驱动程序的OEM)。

你想通过公共API无法完成的驱动程序试图做什么?

+0

我不打算将应用提交给商店。由于电容式按钮的背光控制,我需要访问驱动程序。 – Clocker