快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

vb.net添加到启动项,vb设置启动窗体

vb.net中如何设置启动项

在右侧解决方案资源管理器窗口下右击工程名,点击属性对话框,在出现的界面中点击应用程序选项卡,里面有一个启动窗体选项,你可以自由设置。

创新互联坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都网站设计、做网站、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的修武网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!

VB设置开机启动项

把以下代码复制到Form1.frm里

VERSION 5.00

Begin VB.Form Form1

Caption = "Form1"

ClientHeight = 3030

ClientLeft = 120

ClientTop = 450

ClientWidth = 4560

LinkTopic = "Form1"

ScaleHeight = 3030

ScaleWidth = 4560

StartUpPosition = 3 '窗口缺省

Begin VB.CommandButton Command2

Caption = "删除"

Height = 495

Left = 2160

TabIndex = 1

Top = 480

Width = 1335

End

Begin VB.CommandButton Command1

Caption = "添加"

Height = 615

Left = 360

TabIndex = 0

Top = 360

Width = 1215

End

End

Attribute VB_Name = "Form1"

Attribute VB_GlobalNameSpace = False

Attribute VB_Creatable = False

Attribute VB_PredeclaredId = True

Attribute VB_Exposed = False

'' 关闭打开的键

Private Declare Function RegCloseKey Lib "advapi32.dll" _

(ByVal hKey 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 RegSetValueEx Lib "advapi32" Alias "RegSetValueExA" ( _

ByVal hKey As Long, ByVal lpValueName As String, _

ByVal Reserved As Long, ByVal dwType As Long, _

ByVal lpData As String, 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

'打开注册表subkey的hkey

Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" ( _

ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long

'得到注册表中的键值

Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" ( _

ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, _

lpData As Any, lpcbData As Long) As Long

Private Const HKEY_LOCAL_MACHINE = H80000002

Private Const REG_SZ = 1

Private Sub Command1_Click()

'把应用程序加入自运行

Dim hKey As Long

RegCreateKey HKEY_LOCAL_MACHINE, "SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\RUN", hKey

RegSetValueEx hKey, App.EXEName, 0, REG_SZ, ByVal App.Path "\" App.EXEName ".exe", LenB(StrConv(App.Path "\" App.EXEName ".exe", vbFromUnicode)) + 1

RegCloseKey hKey

MsgBox "成功加入启动项", , "提示"

End Sub

'注:RegSetValeEx的第五个值可改为 ByVal RegXy,第六句可改为 lenB(RegXy)

'Dim RegXy as long:RegXy =app.path "\记事薄.exe"

'regsetvalueex第二项为空时把值填入第一行的默认项,非空时,把值填入指定项目中的最后一行

Private Sub Command2_Click()

'把应用程序退出自运行

Dim hKey As Long, ret As Long '打开键的句柄

RegOpenKey HKEY_LOCAL_MACHINE, "SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\RUN", hKey

ret = RegDeleteValue(hKey, App.EXEName)

If ret 0 Then

MsgBox "HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\RUN\" App.EXEName "不存在"

Exit Sub

End If

RegCloseKey hKey

MsgBox "成功删除启动项", vbOKOnly, "提示"

End Sub

Private Sub Command3_Click()

Dim hKey As Long, ret As Long '打开键的句柄

Dim Name As String * 255, lngTypeData As Long

Dim intname1 As Integer

RegOpenKey HKEY_LOCAL_MACHINE, "SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\RUN", hKey

RegQueryValueEx hKey, App.EXEName, 0, lngTypeData, ByVal Name, Len(Name)

'返回command项App.EXEName

intname1 = InStr(Name, App.EXEName)

If intname1 0 Then

Label1.Caption = Left(Name, InStr(Name, Chr(0)) - 1)

Else

MsgBox "没有值:" App.EXEName, vbOKOnly Or vbInformation, "提示"

Label1.Caption = vbNullString

End If

RegCloseKey hKey

End Sub

用vb语句怎么把程序添加到启动项里

就把程序的本身或者快捷方式放到

C:\Documents and Settings\All Users\「开始」菜单\程序\启动\

里面。

用copy "" to ""之类的。

怎样实现vb.net的开机自动运行

将你自己的程序添加到注册表的开机启动项中 具体路径如图所示


分享题目:vb.net添加到启动项,vb设置启动窗体
转载来源:http://6mz.cn/article/dssddjd.html

其他资讯