放到 所有程序、启动 文件夹zhong2 通过修该注册表 你可以到百度找相关教程3 系统服务启动 利用编程有点难 可以用INF文件来启动较方便4 注入IE什么的 写个DLL注入启动5 镜像劫持6 替换系统文件你百度试试我思路
给你提供我用到的代码:
'初始化全局变量
Option Explicit
Public pathini As String
Public mark As Integer '控制是否自启动的标志变量(1自启动,0不自启动)
'添加删除自启动项目的API函数声明
Public Const HKEY_CLASSES_ROOT = &H80000000
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const HKEY_USERS = &H80000003
Public Const HKEY_PERFORMANCE_DATA = &H80000004
Public Const HKEY_CURRENT_CONFIG = &H80000005
Public Const HKEY_DYN_DATA = &H80000006
Public Const REG_NONE = 0
Public Const REG_SZ = 1
Public Const REG_EXPAND_SZ = 2
Public Const REG_BINARY = 3
Public Const REG_DWORD = 4
Public Const REG_DWORD_BIG_ENDIAN = 5
Public Const REG_MULTI_SZ = 7
Declare Function RegOpenKey Lib "advapi32dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Declare Function RegCreateKey Lib "advapi32dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Declare Function RegCloseKey Lib "advapi32dll" (ByVal hKey As Long) As Long
Declare Function RegSetValue Lib "advapi32dll" Alias "RegSetValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
Declare Function RegSetValueEx Lib "advapi32dll" 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
Declare Function RegDeleteValue Lib "advapi32dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
'在注册表中添加删除自启动项目的模块
Sub Main()
' 定义hKey 为句柄变量、SubKey为注册表RUN项目变量、Exe为程序名变量
Dim hKey As Long, SubKey As String, Exe As String
'将程序设定成随 Windows 启动而启动
'取程序所在路径,判断是否为根目录并分别加上程序全名并赋值给变量Exe
If Right(AppPath, 1) = "\" Then
Exe = AppPath + AppEXEName + "exe" ' 根目录情况
Else: Exe = AppPath + "\" + AppEXEName + "exe" ' 非根目录情况
End If
SubKey = "Software\Microsoft\Windows\CurrentVersion\Run" ' 设置项目
RegCreateKey HKEY_LOCAL_MACHINE, SubKey, hKey ' 取得句柄
RegSetValueEx hKey, "时间助手", 0, REG_SZ, ByVal Exe, LenB(StrConv(Exe, vbFromUnicode)) + 1 ' 写入键值
RegCloseKey hKey ' 关闭句柄
End Sub
自己看吧,很简单的,修改一下就可以用了
程序源代码如下:
main()
{
int i,j,k;
printf("\n");
for(i=1;i<5;i++)/以下为三重循环/
for(j=1;j<5;j++)
for (k=1;k<5;k++)
{
if (i!=k&&i!=j&&j!=k)/确保i、j、k三位互不相同/
printf("%d,%d,%d\n",i,j,k);
}
}
main()
{
long int i;
int bonus1,bonus2,bonus4,bonus6,bonus10,bonus;
scanf("%ld",&i);
bonus1=10000001;bonus2=bonus1+100000075;
bonus4=bonus2+20000005;
bonus6=bonus4+20000003;
bonus10=bonus6+400000015;
if(i<=100000)
bonus=i01;
else if(i<=200000)
bonus=bonus1+(i-100000)0075;
else if(i<=400000)
bonus=bonus2+(i-200000)005;
else if(i<=600000)
bonus=bonus4+(i-400000)003;
else if(i<=1000000)
bonus=bonus6+(i-600000)0015;
else
bonus=bonus10+(i-1000000)001;
printf("bonus=%d",bonus);
}
把程序放入
C:\Documents and Settings\All Users\开始\程序\启动
这个文件夹中,不只VB脚本,其他的bat (批处理程序) exe(应用程序) 也可以放进去运行的这个文件夹中的程序都是开机自动运行的
上面的路径中,All Users针对所有用户,你也可以针对某个用户单独改变
给你段代码:VB编写使程序开机自动启动
'使用下面这三个API与两个常数(标记部份为快捷键方式增加到开始下的启动)
Private
Declare
Function
RegSetValue
Lib
"advapi32dll"
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
"advapi32dll"
Alias
"RegCreateKeyA"
(ByVal
hKey
As
Long,
ByVal
lpSubKey
As
String,
phkResult
As
Long)
As
Long
Private
Declare
Function
RegCloseKey
Lib
"advapi32dll"
(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\abcexe",
4
'关闭对主键的 *** 作
RegCloseKey
Ret2
End
Sub
窗口总是在最前面
Option
Explicit
以上就是关于VB设置开机启动项全部的内容,包括:VB设置开机启动项、VB开机自动运行代码、vb.net实现开机自启等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)