I tried to change the Local Group Policy settings (Remove computer icon on dekstop, Removes windows explorer's default context menu, etc.) using the registry. The state in Group Policy(enable/disable) does affect but the actual(removing computer icon, no context menu/right click) does not. I've found a thread here that to use SendNotifyMessage to apply that change in the registry. Found a source code from pinvoke.net and tried to use it.

Imports System.Runtime.InteropServices

Public Class Form1

    Public Shared ReadOnly HWND_BROADCAST As New IntPtr(&HFFFF)
    Public Const WM_SETTINGCHANGE As Integer = &H1A 'it should be &H001A

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        TextBox1.Text = SendNotifyMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0)
    End Sub

    <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    Public Shared Function SendNotifyMessage( _
     ByVal hWnd As IntPtr, _
     ByVal msg As UInteger, _
     ByVal wParam As UIntPtr, _
     ByVal lParam As IntPtr _
     ) As Boolean
    End Function
End Class

It returns True, but does not work. Is there any wrong in the code? Are there any alternatives? Thank you in advance for any help ^_^

Recommended Answers

All 3 Replies

Don't it need reboot or something after you performed that so that the effect can be visible or take effect? try restarting your computer after firing that code and see.

Well, that is another problem (sorry that i didn't mentioned it before).
I will use this for my Internet Cafe Software on the client-side. I want the settings to be enabled while the software is open and disable it when the admin login and closes the software, then reenables it again if the software is open. Somewhat like a security or admin access only.

oAnd also, it does no need any restart because the effect works immediately by Local Group Policy. but the change does not apply using the registry.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.