Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
刷新桌面-VB.NET_Vb.net - Fatal编程技术网

刷新桌面-VB.NET

刷新桌面-VB.NET,vb.net,Vb.net,我正在尝试刷新桌面,尝试了这个 Private Declare Function SHChangeNotify Lib "Shell32.dll" (ByVal wEventID As Long, ByVal uFlags As Long, ByVal dwItem1 As Long, ByVal dwItem2 As Long) As Long call SHChangeNotify(&H8000000&, &H0, vbNullString, vbNullStrin

我正在尝试刷新桌面,尝试了这个

Private Declare Function SHChangeNotify Lib "Shell32.dll" (ByVal wEventID As Long,
ByVal uFlags As Long, ByVal dwItem1 As Long, ByVal dwItem2 As Long) As Long

call SHChangeNotify(&H8000000&, &H0, vbNullString, vbNullString)
但它给了我错误


刷新桌面的正确方法是什么?

您需要从方法中调用SHCangeNotify(&H8000000,&H0,Nothing,Nothing),例如:

Public Class example

    Private Declare Function SHChangeNotify Lib "Shell32.dll" (ByVal wEventID As Long, _
                                                               ByVal uFlags As Long, _
                                                               ByVal dwitem1 As Long, _
                                                               ByVal deitem2 As Long) As Long

    Private Sub refreshWindow()

    SHCangeNotify(SHChangeNotify(&H8000000, &H0, Nothing, Nothing)

    End Sub

End Class

对于.NET来说,PInvoke似乎不正确。看,那是修订的代码吗?调用需要位于在win8中运行的sub/routineShell32.dll中。它在xp和win7中运行吗?他是说
调用..
代码需要在类似子函数或函数的地方,它不能只是挂在声明的地方