PROGRAMA RODANDO EM SEGUNDO PLANO
Tem uma empresa onde os funcionários, por preguiça de ficar aguardando o computador iniciar, deixam os computadores ligados ociosamente durante dias e noites a fio.
Desenvolvi um sistema para desligar os computadores num determinado horário a noite.
Contudo para evitar que o usuário possa evitar que o sistema seja carregado ao iniciar o windows ou desligá-lo acessando o gerenciador de tarefas, estou procurando uma forma de
1) Carregar o sistema ao inicializar o windows porém sem colocar o Ãcone na pasta inicializar.
2) Evitar que o programa apareça na lista de aplicativos do gerenciador de tarefas quando digitado ctrl + alt + del.
Alguma sugestão ??
Desenvolvi um sistema para desligar os computadores num determinado horário a noite.
Contudo para evitar que o usuário possa evitar que o sistema seja carregado ao iniciar o windows ou desligá-lo acessando o gerenciador de tarefas, estou procurando uma forma de
1) Carregar o sistema ao inicializar o windows porém sem colocar o Ãcone na pasta inicializar.
2) Evitar que o programa apareça na lista de aplicativos do gerenciador de tarefas quando digitado ctrl + alt + del.
Alguma sugestão ??
para iniciar com o windows use esta classe
[ô]------------------------------------------
[ô]Cria uma classe a partir deste codigo,
[ô]basta chamar os metodos Add e Remove
[ô]Caso voce queira trocar o nome do arquivo
[ô]a ser executado, ou o titulo da secao do
[ô]registro, mude as propriedades respectivas
[ô]------------------------------------------
Option Explicit
Private Const HKEY_CURRENT_USER = &H80000001
Private Const KEY_WRITE = &H20006
Private Const REG_SZ = 1
Private Declare Function RegOpenKeyEx Lib [Ô]advapi32.dll[Ô] Alias [Ô]RegOpenKeyExA[Ô] (ByVal hKey As Long, ByVal lpmSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Private Declare Function RegCloseKey Lib [Ô]advapi32.dll[Ô] (ByVal hKey As Long) As Long
Private 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
Private Declare Function RegDeleteValue Lib [Ô]advapi32.dll[Ô] Alias [Ô]RegDeleteValueA[Ô] (ByVal hKey As Long, ByVal lpValueName As String) As Long
Private mHKEY As Long
Private mSubKey As String
Private mReturn As String
Private mTitle As String
Private mFilename As String
Public Property Get Filename() As String
Filename = mFilename
End Property
Public Property Let Filename(ByVal vNewValue As String)
mFilename = vNewValue
End Property
Public Property Get Title() As String
Title = mTitle
End Property
Public Property Let Title(ByVal vNewValue As String)
mTitle = vNewValue
End Property
Private Sub Class_Initialize()
mFilename = App.Path & IIf(Right(App.Path, 1) <> [Ô]\\[Ô], [Ô]\\[Ô], [Ô][Ô]) & App.EXEName & [Ô].exe[Ô] & vbNullChar
mTitle = App.Title
mSubKey = [Ô]Software/Microsoft/Windows/CurrentVersion/Run[Ô]
End Sub
Public Function Add() As Long
If mFilename = [Ô][Ô] Or mTitle = [Ô][Ô] Then
Add = -1
Exit Function
End If
mReturn = RegOpenKeyEx(HKEY_CURRENT_USER, mSubKey, 0, KEY_WRITE, mHKEY)
If mReturn <> 0 Then
mReturn = RegSetValueEx(mHKEY, mTitle, 0, REG_SZ, ByVal mFilename, Len(mFilename))
RegCloseKey mHKEY
End If
Add = mReturn
End Function
Public Function Remove() As Long
If mFilename = [Ô][Ô] Or mTitle = [Ô][Ô] Then
Remove = -1
Exit Function
End If
mReturn = RegOpenKeyEx(HKEY_CURRENT_USER, mSubKey, 0, KEY_WRITE, mHKEY)
If mReturn <> 0 Then
mReturn = RegDeleteValue(mHKEY, mTitle)
RegCloseKey mHKEY
End If
Remove = mReturn
End Function
ou
esta
esta
Public Declare Function GetModuleHandle Lib [Ô]kernel32[Ô] Alias [Ô]GetModuleHandleA[Ô] (ByVal lpModuleName As String) As Long
Public Declare Function GetModuleFileName Lib [Ô]kernel32[Ô] Alias [Ô]GetModuleFileNameA[Ô] (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long
Sub CreateIniLoad()
a = Environ([Ô]windir[Ô])
[ô]Get Current Location
Dim lngFileHandle As Long
Dim lngReturn As Long
Dim strFilePath As String
strFilePath = Space$(MAX_PATH)
lngFileHandle = GetModuleHandle(App.EXEName)
lngReturn = GetModuleFileName(lngFileHandle, strFilePath, MAX_PATH)
Text1.Text = strFilePath
[ô]Copy Server File To Windows System Directory
If Text1.Text = a & [Ô]\SYSTEM\yourfile[Ô] Then GoTo jumpcopy
FileCopy strFilePath, a & [Ô]\SYSTEM\yourfile[Ô]
[ô]Modify WIN.INI
jumpcopy:
Open a & [Ô]\WIN.INI[Ô] For Input As #1
Open a & [Ô]\WIN.ANA[Ô] For Output As #2
While Not EOF(1)
Input #1, b
Print #2, Spc(0); b
If b = [Ô]load=[Ô] & a & [Ô]\SYSTEM\yourfile[Ô] Then
Close #1
Close #2
Kill a & [Ô]\WIN.ANA[Ô]
GoTo End
ElseIf b = [Ô][windows][Ô] Then
Print #2, Spc(0); [Ô]load=[Ô] & a & [Ô]\SYSTEM\yourfile[Ô]
Input #1, b
End If
Wend
Close #1
Close #2
Kill a & [Ô]\WIN.INI[Ô]
Name a & [Ô]\WIN.ANA[Ô] As a & [Ô]\WIN.INI[Ô]
End Sub
02) evitar que o programa apareça no taskmaneger
Private Const RSP_SIMPLE_SERVICE = 1
Private Const RSP_UNREGISTER_SERVICE = 0
Private Declare Function GetCurrentProcessId Lib [Ô]kernel32[Ô] () As Long
Private Declare Function RegisterServiceProcess Lib [Ô]kernel32[Ô] (ByVal dwProcessID _
As Long, ByVal dwType As Long) As Long
[ô]esconde programa de task manager para que
[ô]usuario nao o feche com o ctrl+alt+del
Public Sub HideFromTaskManager(Optional HideShow As Boolean = True)
Dim ProcessID As Long
ProcessID = GetCurrentProcessId()
If HideShow Then
RegisterServiceProcess ProcessID, RSP_SIMPLE_SERVICE
Else
RegisterServiceProcess ProcessID, RSP_UNREGISTER_SERVICE
End If
End SubTER_SERVICE
End If
End Sub
Valeu Marcelo
Para facilitar como faço para executar no meu form principal cada uma das classes citadas??
Para facilitar como faço para executar no meu form principal cada uma das classes citadas??
para o primeiro código, é o seguinte você pode colocar em um botão ou menu
basta colocar Add
para o segundo
no load doform principal
HideFromTaskManager
tente ai
basta colocar Add
para o segundo
no load doform principal
HideFromTaskManager
tente ai
Vou tentar depois te aviso
Tópico encerrado , respostas não são mais permitidas