Привет! А теперь приступим к одной очень важно вещи... Сокрытие из диспетчера задач. На самом деле в первом случае мы частично скроем прогу, а во втором просто запретим открытие диспетчера. Сразу говорю я дам два, полноценно работающих варианта под XP. На счет Vist'ы я не уверен. Итак. ________________________________________________________________________________________________________ Option Explicit Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long Const SW_HIDE = 0 Const GW_OWNER = 4
Private Sub Form_Load() Dim OwnerhWnd As Long 'дескриптор окна программы Dim ret As Long OwnerhWnd = GetWindow(Me.hwnd, GW_OWNER) 'Получаем дескриптор окна программы ret = ShowWindow(OwnerhWnd, SW_HIDE) 'скрываем в диспетчере задач End Sub
Этот скроет вас изх вкладки "Приложения" ________________________________________________________________________________________________________
Ну а второй довольно длинный, но зато самый эффективный. Для начала создай модуль и вставь туда вот это:
Public Const REG_SZ As Long = 1 Public Const REG_DWORD As Long = 4 Public Const HKEY_CURRENT_USER = &H80000001 Public Const KEY_ALL_ACCESS = &H3F Public Const REG_OPTION_NON_VOLATILE = 0 Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, ByVal lpSecurityAttributes As Long, phkResult As Long, lpdwDisposition As Long) As Long Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long Declare Function RegSetValueExString Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpValue As String, ByVal cbData As Long) As Long Declare Function RegSetValueExLong Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpValue As Long, ByVal cbData As Long) As Long Declare Function RegDeleteValue& Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) Public Function CreateNewKey(lPredefinedKey As Long, sNewKeyName As String) Dim hNewKey As Long Dim lRetVal As Long lRetVal = RegCreateKeyEx(lPredefinedKey, sNewKeyName, 0&, vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0&, hNewKey, lRetVal) RegCloseKey (hNewKey) End Function Public Function SetKeyValue(lPredefinedKey As Long, sKeyName As String, sValueName As String, vValueSetting As Variant, lValueType As Long) Dim lRetVal As Long Dim hKey As Long lRetVal = RegOpenKeyEx(lPredefinedKey, sKeyName, 0, KEY_ALL_ACCESS, hKey) lRetVal = SetValueEx(hKey, sValueName, lValueType, vValueSetting) RegCloseKey (hKey) End Function Public Function SetValueEx(ByVal hKey As Long, sValueName As String, lType As Long, vValue As Variant) As Long Dim lValue As Long Dim sValue As String Select Case lType Case REG_SZ sValue = vValue SetValueEx = RegSetValueExString(hKey, sValueName, 0&, lType, sValue, Len(sValue)) Case REG_DWORD lValue = vValue SetValueEx = RegSetValueExLong(hKey, sValueName, 0&, lType, lValue, 4) End Select End Function Public Function DeleteValue(lPredefinedKey As Long, sKeyName As String, sValueName As String) Dim lRetVal As Long Dim hKey As Long lRetVal = RegOpenKeyEx(lPredefinedKey, sKeyName, 0, KEY_ALL_ACCESS, hKey) lRetVal = RegDeleteValue(hKey, sValueName) RegCloseKey (hKey) End Function
Затем на форму кинь две кнопки. На первой напиши "Разрешить", на другой "Запретить"
Private Sub Command1_Click() DeleteValue HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr" End Sub
Private Sub Command2_Click() CreateNewKey HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Policies\System" SetKeyValue HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", "1", REG_DWORD End Sub
Вот и все. Кто узнал отсюда много полезного, обязательно пишите положительные комменты. Все кто желает заняться написанием статей пишите в форуме.
|