求一个VB程序代码~要在进程中隐藏的~开机自动启动的~窗口总是在最前面的~这些代码要合起来~~要能生成exe的

求一个VB程序代码~要在进程中隐藏的~开机自动启动的~窗口总是在最前面的~这些代码要合起来~~要能生成exe的代码有错误不能生成EXE~~我用的是VB6.0请帮我改正确谢... 求一个VB程序代码~要在进程中隐藏的~开机自动启动的~窗口总是在最前面的~这些代码要合起来~~要能生成exe的
代码有错误不能生成EXE~~我用的是VB6.0请帮我改正确谢谢
展开
 我来答
养田然UV
2009-07-03 · TA获得超过468个赞
知道答主
回答量:28
采纳率:0%
帮助的人:19.5万
展开全部
在进程中隐藏的
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
studydesign
2009-07-03 · TA获得超过2329个赞
知道小有建树答主
回答量:1618
采纳率:0%
帮助的人:1182万
展开全部
搞木马你被车七十码
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
253032410
2009-07-03 · TA获得超过435个赞
知道答主
回答量:114
采纳率:0%
帮助的人:87.1万
展开全部
得用到很多API。。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式