Results 1 to 5 of 5

Thread: use Ctrl+Atl+Delete to trigger an event?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2002
    Posts
    2

    use Ctrl+Atl+Delete to trigger an event?

    i'm a beginner in vb still studying in college, so my question might seem a little stupid for some of you. in my vb project, is it possible to trigger an event procedure when the user presses the Ctrl+Atl+Delete keys on my form? (without causing the windows task manager to pop up) i'm running windows 2000 and xp professonal. can anyone send me codes or tell me where i can find codes for doing this? thank you in advance

  2. #2
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    put a button called Disable, and a button called Enable. make a module and put this code in:
    VB Code:
    1. 'In module
    2. '**************************************
    3. 'Windows API/Global Declarations for :Di
    4. '     sable Ctrl-Alt-Del in NT,2000,XP
    5. '**************************************
    6. Public Const HKEY_CLASSES_ROOT = &H80000000
    7. Public Const HKEY_CURRENT_USER = &H80000001
    8. Public Const HKEY_LOCAL_MACHINE = &H80000002
    9. Public Const HKEY_USERS = &H80000003
    10. Public Const HKEY_PERFORMANCE_DATA = &H80000004
    11. Public Const ERROR_SUCCESS = 0&
    12.  
    13.  
    14. Declare Function RegCloseKey Lib "advapi32.dll" (ByVal Hkey As Long) As Long
    15.  
    16.  
    17. Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    18.  
    19.  
    20. Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String) As Long
    21.  
    22.  
    23. Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal Hkey As Long, ByVal lpValueName As String) As Long
    24.  
    25.  
    26. Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    27.  
    28.  
    29. Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
    30.  
    31.  
    32. Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
    33.     Public Const REG_SZ = 1 ' Unicode nul terminated String
    34.     Public Const REG_DWORD = 4 ' 32-bit number
    35.  
    36.  
    37. Public Sub savekey(Hkey As Long, strPath As String)
    38.     Dim keyhand&
    39.     r = RegCreateKey(Hkey, strPath, keyhand&)
    40.     r = RegCloseKey(keyhand&)
    41. End Sub
    42.  
    43.  
    44. Public Function getstring(Hkey As Long, strPath As String, strValue As String)
    45.     'EXAMPLE:
    46.     '
    47.     'text1.text = getstring(HKEY_CURRENT_USE
    48.     '
    49.     ' R, "Software\VBW\Registry", "String")
    50.     '
    51.     Dim keyhand As Long
    52.     Dim datatype As Long
    53.     Dim lResult As Long
    54.     Dim strBuf As String
    55.     Dim lDataBufSize As Long
    56.     Dim intZeroPos As Integer
    57.     r = RegOpenKey(Hkey, strPath, keyhand)
    58.     lResult = RegQueryValueEx(keyhand, strValue, 0&, lValueType, ByVal 0&, lDataBufSize)
    59.  
    60.  
    61.     If lValueType = REG_SZ Then
    62.         strBuf = String(lDataBufSize, " ")
    63.         lResult = RegQueryValueEx(keyhand, strValue, 0&, 0&, ByVal strBuf, lDataBufSize)
    64.  
    65.  
    66.         If lResult = ERROR_SUCCESS Then
    67.             intZeroPos = InStr(strBuf, Chr$(0))
    68.  
    69.  
    70.             If intZeroPos > 0 Then
    71.                 getstring = Left$(strBuf, intZeroPos - 1)
    72.             Else
    73.                 getstring = strBuf
    74.             End If
    75.         End If
    76.     End If
    77. End Function
    78.  
    79.  
    80. Public Sub savestring(Hkey As Long, strPath As String, strValue As String, strdata As String)
    81.     'EXAMPLE:
    82.     '
    83.     'Call savestring(HKEY_CURRENT_USER, "Sof
    84.     '
    85.     ' tware\VBW\Registry", "String", text1.t
    86.     '     ex
    87.     ' t)
    88.     '
    89.     Dim keyhand As Long
    90.     Dim r As Long
    91.     r = RegCreateKey(Hkey, strPath, keyhand)
    92.     r = RegSetValueEx(keyhand, strValue, 0, REG_SZ, ByVal strdata, Len(strdata))
    93.     r = RegCloseKey(keyhand)
    94. End Sub
    95.  
    96.  
    97. Function getdword(ByVal Hkey As Long, ByVal strPath As String, ByVal strValueName As String) As Long
    98.     'EXAMPLE:
    99.     '
    100.     'text1.text = getdword(HKEY_CURRENT_USER
    101.     '
    102.     ' , "Software\VBW\Registry", "Dword")
    103.     '
    104.     Dim lResult As Long
    105.     Dim lValueType As Long
    106.     Dim lBuf As Long
    107.     Dim lDataBufSize As Long
    108.     Dim r As Long
    109.     Dim keyhand As Long
    110.     r = RegOpenKey(Hkey, strPath, keyhand)
    111.     ' Get length/data type
    112.     lDataBufSize = 4
    113.     lResult = RegQueryValueEx(keyhand, strValueName, 0&, lValueType, lBuf, lDataBufSize)
    114.  
    115.  
    116.     If lResult = ERROR_SUCCESS Then
    117.  
    118.  
    119.         If lValueType = REG_DWORD Then
    120.             getdword = lBuf
    121.         End If
    122.         'Else
    123.         'Call errlog("GetDWORD-" & strPath, Fals
    124.         '
    125.         ' e)
    126.     End If
    127.     r = RegCloseKey(keyhand)
    128. End Function
    129.  
    130.  
    131. Function SaveDword(ByVal Hkey As Long, ByVal strPath As String, ByVal strValueName As String, ByVal lData As Long)
    132.     'EXAMPLE"
    133.     '
    134.     'Call SaveDword(HKEY_CURRENT_USER, "Soft
    135.     '     ware\VBW\Registry", "Dword", text1.text)
    136.     '
    137.     '
    138.     '
    139.     Dim lResult As Long
    140.     Dim keyhand As Long
    141.     Dim r As Long
    142.     r = RegCreateKey(Hkey, strPath, keyhand)
    143.     lResult = RegSetValueEx(keyhand, strValueName, 0&, REG_DWORD, lData, 4)
    144.     'If lResult <> error_success Then
    145.     ' Call errlog("SetDWORD", False)
    146.     r = RegCloseKey(keyhand)
    147. End Function
    148.  
    149.  
    150. Public Function DeleteKey(ByVal Hkey As Long, ByVal strKey As String)
    151.     'EXAMPLE:
    152.     '
    153.     'Call DeleteKey(HKEY_CURRENT_USER, "Soft
    154.     '
    155.     ' ware\VBW")
    156.     '
    157.     Dim r As Long
    158.     r = RegDeleteKey(Hkey, strKey)
    159. End Function
    160.  
    161.  
    162. Public Function DeleteValue(ByVal Hkey As Long, ByVal strPath As String, ByVal strValue As String)
    163.     'EXAMPLE:
    164.     '
    165.     'Call DeleteValue(HKEY_CURRENT_USER, "So
    166.     '
    167.     ' ftware\VBW\Registry", "Dword")
    168.     '
    169.     Dim keyhand As Long
    170.     r = RegOpenKey(Hkey, strPath, keyhand)
    171.     r = RegDeleteValue(keyhand, strValue)
    172.     r = RegCloseKey(keyhand)
    173. End Function

    now, in your form with you command buttons put this in:

    VB Code:
    1. 'In form
    2.  
    3. Private Sub Disable_Click()
    4.     Call SaveDword(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", "1")
    5. End Sub
    6.  
    7.  
    8. Private Sub Enable_Click()
    9.     Call SaveDword(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", "0")
    10. End Sub

    this will disable the task manager in NT(NT/2000/XP).

    for NON-NT (95/98/ME) search the site.
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2002
    Posts
    2
    THANK YOU!!!

    now how can i ust Ctrl+Alt+Delete to trigger an event? i know that the Ctrl and Atl key do not have an ACSII code so how should i do this? thx again

  4. #4
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    i dunno.
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  5. #5
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    i dunno.
    classic...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width