hi all,
i new for vb.net. i try to disable windows key function using vb.net. But by code only work on mouse click.
so i need help to edit my code.
This my code.
Thanks,

Option Strict On
Imports System.Runtime.InteropServices
Public Class Form1
    <DllImport("user32.dll")>
    Private Shared Function FindWindow(className As String, windowText As String) As Integer
    End Function
    <DllImport("user32.dll")>
    Private Shared Function EnableWindow(ByVal hWnd As IntPtr, ByVal bEnable As Boolean) As Boolean
    End Function
    Dim StartButtonhWnd As Integer = 0
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        EnableWindow(CType(StartButtonhWnd, IntPtr), True)
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        StartButtonhWnd = FindWindow("Button", "Start")
        EnableWindow(CType(StartButtonhWnd, IntPtr), False)
    End Sub
End Class

Recommended Answers

All 2 Replies

Hi Rammanan, welcome at daniweb.
You got to intercept one of the key events( KeyPress, KeyDown or KeyUp )instead of the Click event. Example.

Hi Rammanan, welcome at daniweb.
You got to intercept one of the key events( KeyPress, KeyDown or KeyUp )instead of the Click event. Example.

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.