Private Declare Function GetCurrentProcessId Lib ″kernel32″ () As Long Private Declare Function RegisterServiceProcess Lib ″kernel32″ (ByVal dwProcessID As Long, _ ByVal dwType As Long) As Long Private Const RSP_SIMPLE_SERVICE = 1 Private Const RSP_UNREGISTER_SERVICE = 0 Dim pid As Long Dim regserv As Long pid = GetCurrentProcessId() ′得到当前进程ID regserv = RegisterServiceProcess(pid, RSP_SIMPLE_SERVICE) ′把本程序注册为service
不用get自己的进程id dwProcessID传入null就是默认当前进程
To jlum99兄: 谢谢你教给我一个好办法。可是为什么出现了“找不到dll入口点”错误? 另外,什么是服务程序?谢谢!
禁用Ctrl-Alt-Del Private Declare Function EnableWindow Lib "user32" (ByVal hWnd As Integer, ByVal aBOOL As Integer) As Integer Private Declare Function IsWindowEnabled Lib "user32" (ByVal hWnd As Integer) As Integer Private Declare Function GetMenu Lib "user32" (ByVal hWnd As Integer) As Integer Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function SystemParametersInfo Lib "user32" Alias " SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long Private TaskBarhWnd As Long Private IsTaskBarEnabled As Integer Private TaskBarMenuHwnd As Integer '禁止使用Ctrl-Alt-Del Public Sub DisableTaskBar() Dim EWindow As Integer TaskBarhWnd = FindWindow("Shell_traywnd", "") If TaskBarhWnd <> 0 Then EWindow = IsWindowEnabled(TaskBarhWnd) If EWindow = 1 Then IsTaskBarEnabled = EnableWindow(TaskBarhWnd, 0) End If End If End Sub '允许使用Ctrl-Alt-Del Public Sub EnableTaskBar() If IsTaskBarEnabled = 0 Then IsTaskBarEnabled = EnableWindow(TaskBarhWnd, 1) End If End Sub '禁止 Ctrl+Alt+Del ' 声明(For Win95): Const SPI_SCREENSAVERRUNNING = 97 Private Declare Function SystemParametersInfo Lib "user32" Alias " SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As Long 使用: '禁止 Dim pOld As Boolean Call SystemParametersInfo(SPI_SCREENSAVERRUNNING, True, pOld, 0) '开启 Dim pOld As Boolean Call SystemParametersInfo(SPI_SCREENSAVERRUNNING, False, pOld, 0) 或者 Private Declare Function SystemParametersInfo Lib _ "user32" Alias "SystemParametersInfoA" (ByVal uAction _ As Long, ByVal uParam As Long, ByVal lpvParam As Any, _ ByVal fuWinIni As Long) As Long 自定义函数在Form_Load事件中调用即可 Sub DisableCtrlAltDelete(Flags As Boolean) ' Disables Control Alt Delete Breaking as well as Ctrl-Escape Dim X As Long X = SystemParametersInfo(97, Flags, CStr(1), 0) End Sub
只能用RegisterServiceProcess
此函数没有在api loader中出现,只能自己写。
你想干什么?
Private Declare Function RegisterServiceProcess Lib ″kernel32″ (ByVal dwProcessID As Long, _ ByVal dwType As Long) As Long
Private Const RSP_SIMPLE_SERVICE = 1
Private Const RSP_UNREGISTER_SERVICE = 0
Dim pid As Long
Dim regserv As Long
pid = GetCurrentProcessId() ′得到当前进程ID
regserv = RegisterServiceProcess(pid, RSP_SIMPLE_SERVICE) ′把本程序注册为service
dwProcessID传入null就是默认当前进程
谢谢你教给我一个好办法。可是为什么出现了“找不到dll入口点”错误?
另外,什么是服务程序?谢谢!
Private Declare Function EnableWindow Lib "user32" (ByVal hWnd As
Integer, ByVal aBOOL As Integer) As Integer
Private Declare Function IsWindowEnabled Lib "user32" (ByVal hWnd As
Integer) As Integer
Private Declare Function GetMenu Lib "user32" (ByVal hWnd As Integer) As
Integer
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (
ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SystemParametersInfo Lib "user32" Alias "
SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long,
ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
Private TaskBarhWnd As Long
Private IsTaskBarEnabled As Integer
Private TaskBarMenuHwnd As Integer
'禁止使用Ctrl-Alt-Del
Public Sub DisableTaskBar()
Dim EWindow As Integer
TaskBarhWnd = FindWindow("Shell_traywnd", "")
If TaskBarhWnd <> 0 Then
EWindow = IsWindowEnabled(TaskBarhWnd)
If EWindow = 1 Then
IsTaskBarEnabled = EnableWindow(TaskBarhWnd, 0)
End If
End If
End Sub
'允许使用Ctrl-Alt-Del
Public Sub EnableTaskBar()
If IsTaskBarEnabled = 0 Then
IsTaskBarEnabled = EnableWindow(TaskBarhWnd, 1)
End If
End Sub
'禁止 Ctrl+Alt+Del
' 声明(For Win95):
Const SPI_SCREENSAVERRUNNING = 97
Private Declare Function SystemParametersInfo Lib "user32" Alias "
SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long,
lpvParam As Any, ByVal fuWinIni As Long) As Long
使用:
'禁止
Dim pOld As Boolean
Call SystemParametersInfo(SPI_SCREENSAVERRUNNING, True, pOld, 0)
'开启
Dim pOld As Boolean
Call SystemParametersInfo(SPI_SCREENSAVERRUNNING, False, pOld, 0)
或者
Private Declare Function SystemParametersInfo Lib _
"user32" Alias "SystemParametersInfoA" (ByVal uAction _
As Long, ByVal uParam As Long, ByVal lpvParam As Any, _
ByVal fuWinIni As Long) As Long
自定义函数在Form_Load事件中调用即可
Sub DisableCtrlAltDelete(Flags As Boolean)
' Disables Control Alt Delete Breaking as well as Ctrl-Escape
Dim X As Long
X = SystemParametersInfo(97, Flags, CStr(1), 0)
End Sub