2015-12-03 93 views
1

我試圖讓到Windows CE 5 API呼叫的呼叫,「FindFirstChangeNotification」在VS2008智能設備項目使用WinCE5 API調用LPCTSTR:麻煩經過串

Private Declare Function FindFirstChangeNotification Lib "coredll.dll" _ 
(ByVal lpPathName As String, ByVal bWatchSubtree As Long, _ 
ByVal dwNotifyFilter As Long) As Long 

Dim strFolderPath As String = "\My Documents\My App Files\" 
Dim ptrHandle as IntPtr = FindFirstChangeNotification(strFolderPath, 0, 1) 

在嘗試此方法將導致一個「System.NotSupportedException」,我認爲它是字符串類型中的不兼容性。儘管嘗試了不同的編組行爲,但在數天後我仍然陷入困境。在Windows CE

回答

1

字符串類型都是Unicode,所以聲明爲String應該是正確的。

Coredll實際上導出功能FindFirstChangeNotificationW(注意尾隨「W」),這樣很可能你得到一個異常的原因。

「W」表示寬,如在寬字符或Unicode,實施的函數。通常,您可以在Visual Studio命令提示符中使用dumpbin工具來識別函數導出的名稱,在這種情況下,我使用dumpbin /exports coredll.dll來檢查。

此外,據我所知,在VB.Net Long是一個64位類型,並且FindFirstChangeNotification需要32位參數。

那麼試試這個:

Private Declare Function FindFirstChangeNotificationW Lib "coredll.dll" _ 
(ByVal lpPathName As String, ByVal bWatchSubtree As Integer, _ 
ByVal dwNotifyFilter As Integer) As Integer 
+0

感謝您的答覆!這是問題。 – GSHinks