PDA

View Full Version : سوال: غیر فعال کردن کلید Start روی کی بورد



mehdi.safavie
پنج شنبه 22 اسفند 1392, 04:58 صبح
درود;
چرا این کد کار نمیکنه ؟


Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyData = Keys.LWin Then
e.SuppressKeyPress = True
End If
End Sub

boveiryghasem
پنج شنبه 22 اسفند 1392, 09:47 صبح
http://www.daniweb.com/software-development/vbnet/threads/279961/want-to-disable-windows-key
http://www.a1vbcode.com/a1vbcode/vbforums/Topic6395-3-1.aspx#bm6405

mehdi.safavie
پنج شنبه 22 اسفند 1392, 18:29 عصر
همه ی این ها رو قبلا گشتم ، یا کدها جواب نمیدن یا ماله VB6 هستن !
کسی دیگه ای نبود ؟

mehdi.safavie
جمعه 23 اسفند 1392, 18:48 عصر
هیشکی بلد نیست این کارو کنه ؟
من این لینک رو پیدا کردم
http://support.microsoft.com/kb/292504
اول این که اون ادرسی که از رجیستری گذاشته و کاری که گفته بکنی برای Task Manager هست !
دوم این که اون همه کاری که اون پایینش توضیح داده ، اگه کسی میفهمه قلقش چطوریه یه توضیحی بده ما خودمون درستش میکنیم !
مثلا برای غیر فعال کردن Task Manager تو اون آدرس یه DWORD میسازیم ، اسمش رو DisableTaskMgr تغییر میدیم و مقدارش رو 0 یا 1 میکنیم !
حالا برای غیر فعال کردن منوی استارت ، قضیه چیه ؟ چیکار باید کرد ؟

mehdi.safavie
شنبه 24 اسفند 1392, 21:05 عصر
مشکل این کد ها چیه ؟
'Event types Private Const WM_KEYUP As Integer = &H101
Private Const WM_KEYDOWN As Short = &H100S
Private Const WM_SYSKEYDOWN As Integer = &H104
Private Const WM_SYSKEYUP As Integer = &H105
'EventInfo structure
PublicStructure KBDLLHOOKSTRUCT
Public vkCode AsInteger
Public scanCode AsInteger
Public flags AsInteger
Public time AsInteger
Public dwExtraInfo AsInteger
EndStructure
'Keyboard hook related functions
Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Integer) As Integer
Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Integer, ByVal lpfn As KeyboardHookDelegate, ByVal hmod As Integer, ByVal dwThreadId As Integer) As Integer
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Integer
Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Integer, ByVal nCode As Integer, ByVal wParam As Integer, ByVal lParam As KBDLLHOOKSTRUCT) As Integer
Private Delegate Function KeyboardHookDelegate(ByVal Code As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer
Private KeyboardHandle As IntPtr = 0 'Handle of the hook
Private callback AsKeyboardHookDelegate=Nothing'Delegate for the hook
Private Function Hooked()
Return KeyboardHandle <> 0 'IfKeyboardHandle=0 it means that it isn't hooked so return false, otherwise return true
End Function
Public Sub HookKeyboard()
callback = New KeyboardHookDelegate(AddressOf KeyboardCallback)
KeyboardHandle = SetWindowsHookEx(13, callback, Process.GetCurrentProcess.MainModule.BaseAddress, 0)
If KeyboardHandle <> 0 Then
Debug.Write(vbCrLf & "[Keyboard Hooked]" & vbCrLf)
End If
End Sub
Public Sub UnhookKeyboard()
If (Hooked()) Then
If UnhookWindowsHookEx(KeyboardHandle) <> 0 Then
Debug.Write(vbCrLf & "[Keyboard Unhooked]")
KeyboardHandle = 0 'We have unhooked successfully
End If
End If
EndSub()
PublicFunctionKeyboardCallback(ByValCodeAsInteger, ByVal wParam AsInteger,ByRef lParam As KBDLLHOOKSTRUCT)AsInteger
'Variable to hold the text describing the key pressed
Dim Key = lParam.vkCode
'Ifeventis KEYDOWN
If wParam = WM_KEYDOWN Or wParam = WM_SYSKEYDOWN Then
'If we can block events
If Code >= 0 Then
If Key = 91 Or Key = 92 Then
Return 1 'Blockevent
End If
End If
End If
Debug.Write(Key)
'Return CallNextHookEx(KeyboardHandle, Code, wParam, lParam) 'Letevent go to the other applications
EndFunction()
PrivateSubForm1_FormClosing(ByVal sender AsObject,ByVal e AsSystem.Windows.Forms.FormClosingEventArgs)Handle sMe.FormClosing
UnhookKeyboard()
EndSub()
PrivateSubForm1_Load(ByVal sender AsSystem.Object,ByVal e AsSystem.EventArgs)HandlesMyBase.Load
HookKeyboard()
EndSub()