求一个VB程序代码~要在进程中隐藏的~开机自动启动的~窗口总是在最前面的~这些代码要合起来~~要能生成exe的
求一个VB程序代码~要在进程中隐藏的~开机自动启动的~窗口总是在最前面的~这些代码要合起来~~要能生成exe的代码有错误不能生成EXE~~我用的是VB6.0请帮我改正确谢...
求一个VB程序代码~要在进程中隐藏的~开机自动启动的~窗口总是在最前面的~这些代码要合起来~~要能生成exe的
代码有错误不能生成EXE~~我用的是VB6.0请帮我改正确谢谢 展开
代码有错误不能生成EXE~~我用的是VB6.0请帮我改正确谢谢 展开
3个回答
展开全部
在进程中隐藏的
Public Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Public Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As Long
Public Const RSP_SIMPLE_SERVICE = 1
Public Const RSP_UNREGISTER_SERVICE = 0
下面代码为隐藏
Public Sub MakeMeService()
Dim pid As Long
Dim reserv As Long
pid = GetCurrentProcessId() '取的当前运行的程序Id
regserv = RegisterServiceProcess(pid, RSP_SIMPLE_SERVICE)
对当前的程序传入 RSP_SIMPLE_SERVICE 消息,使此程序
从任务列表中隐藏
End Sub
'恢复隐藏
Public Sub UnMakeMeService()
Dim pid As Long
Dim reserv As Long
pid = GetCurrentProcessId()
regserv = RegisterServiceProcess(pid, RSP_UNREGISTER_SERVICE)
原理同上
End Sub
Private Sub Command1_Click()
Call MakeMeService
End Sub
Private Sub Command2_Click()
Call UnMakeMeService
End Sub
Private Sub Form_Load()
Form1.Left = Screen.Width / 2 - Form1.Width / 2
Form1.Top = Screen.Height / 2 - Form1.Height / 2
End Sub
开机自动启动
'使用下面这三个API与两个常数(标记部份为快捷键方式增加到开始下的启动)
Private Declare Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_SZ = 1
Private Sub Command1_Click()
Dim Ret2 As Long
'打开 HKEY_LOCAL_MACHINE 下的 software\microsoft\windows\currentVersion\run
RegCreateKey HKEY_LOCAL_MACHINE, "software\microsoft\windows\currentVersion\run", Ret2
'将此主键下的 "默认" 值改为你的 exe 全路径"
RegSetValue Ret2, vbNullString, REG_SZ, "c:\windows\abc.exe", 4
'关闭对主键的操作
RegCloseKey Ret2
End Sub
窗口总是在最前面
Option Explicit
'【VB声明】
' Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function SetWindowPos Lib "user32" ( _
ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal x As Long, ByVal y As Long, _
ByVal cx As Long, ByVal cy As Long, _
ByVal wFlags As Long _
) As Long
Const HWND_TOPMOST = -1
Const SWP_SHOWWINDOW = &H40
Private Sub Form_load()
Dim retValue As Long
'将窗体设置为处于所有窗口的顶层,注意在 VB 中运行时,
’可能不行,但编译成EXE后就可以了
retValue = SetWindowPos(Me.hwnd, HWND_TOPMOST, Me.CurrentX,
Me.CurrentY, 300, 300, SWP_SHOWWINDOW)
End Sub
Public Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Public Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As Long
Public Const RSP_SIMPLE_SERVICE = 1
Public Const RSP_UNREGISTER_SERVICE = 0
下面代码为隐藏
Public Sub MakeMeService()
Dim pid As Long
Dim reserv As Long
pid = GetCurrentProcessId() '取的当前运行的程序Id
regserv = RegisterServiceProcess(pid, RSP_SIMPLE_SERVICE)
对当前的程序传入 RSP_SIMPLE_SERVICE 消息,使此程序
从任务列表中隐藏
End Sub
'恢复隐藏
Public Sub UnMakeMeService()
Dim pid As Long
Dim reserv As Long
pid = GetCurrentProcessId()
regserv = RegisterServiceProcess(pid, RSP_UNREGISTER_SERVICE)
原理同上
End Sub
Private Sub Command1_Click()
Call MakeMeService
End Sub
Private Sub Command2_Click()
Call UnMakeMeService
End Sub
Private Sub Form_Load()
Form1.Left = Screen.Width / 2 - Form1.Width / 2
Form1.Top = Screen.Height / 2 - Form1.Height / 2
End Sub
开机自动启动
'使用下面这三个API与两个常数(标记部份为快捷键方式增加到开始下的启动)
Private Declare Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_SZ = 1
Private Sub Command1_Click()
Dim Ret2 As Long
'打开 HKEY_LOCAL_MACHINE 下的 software\microsoft\windows\currentVersion\run
RegCreateKey HKEY_LOCAL_MACHINE, "software\microsoft\windows\currentVersion\run", Ret2
'将此主键下的 "默认" 值改为你的 exe 全路径"
RegSetValue Ret2, vbNullString, REG_SZ, "c:\windows\abc.exe", 4
'关闭对主键的操作
RegCloseKey Ret2
End Sub
窗口总是在最前面
Option Explicit
'【VB声明】
' Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function SetWindowPos Lib "user32" ( _
ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal x As Long, ByVal y As Long, _
ByVal cx As Long, ByVal cy As Long, _
ByVal wFlags As Long _
) As Long
Const HWND_TOPMOST = -1
Const SWP_SHOWWINDOW = &H40
Private Sub Form_load()
Dim retValue As Long
'将窗体设置为处于所有窗口的顶层,注意在 VB 中运行时,
’可能不行,但编译成EXE后就可以了
retValue = SetWindowPos(Me.hwnd, HWND_TOPMOST, Me.CurrentX,
Me.CurrentY, 300, 300, SWP_SHOWWINDOW)
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询