免费观看又色又爽又黄的小说免费_美女福利视频国产片_亚洲欧美精品_美国一级大黄大色毛片

vb點虐 程序開機自啟 vb系統自動執行啟動窗體

求高手給一個VB.NET的程序開機啟動和關閉開機啟動的示例代碼

Private Sub 開機自動啟動_Click(sender As Object, e As EventArgs) Handles 開機自動啟動.Click

創新互聯建站堅持“要么做到,要么別承諾”的工作理念,服務領域包括:做網站、成都做網站、企業官網、英文網站、手機端網站、網站推廣等服務,滿足客戶于互聯網時代的奉新網站設計、移動媒體設計的需求,幫助企業找到有效的互聯網解決方案。努力成為您成熟可靠的網絡建設合作伙伴!

Dim a As Microsoft.Win32.RegistryKey = My.Computer.Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Run")

a.SetValue("查看.exe", Application.StartupPath "\查看.exe")

End Sub

Private Sub 關閉開機自啟_Click(sender As Object, e As EventArgs) Handles 關閉開機自啟.Click

Dim a As Microsoft.Win32.RegistryKey = My.Computer.Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Run")

a.DeleteValue("查看.exe")

End Sub

VB中怎么讓自己寫的程序在開機時自動啟動?

給你提供我用到的代碼:\x0d\x0a'初始化全局變量\x0d\x0aOption Explicit\x0d\x0aPublic pathini As String\x0d\x0aPublic mark As Integer '控制是否自啟動的標志變量(1自啟動,0不自啟動)\x0d\x0a'添加刪除自啟動項目的API函數聲明\x0d\x0aPublic Const HKEY_CLASSES_ROOT = H80000000\x0d\x0aPublic Const HKEY_CURRENT_USER = H80000001\x0d\x0aPublic Const HKEY_LOCAL_MACHINE = H80000002\x0d\x0aPublic Const HKEY_USERS = H80000003\x0d\x0aPublic Const HKEY_PERFORMANCE_DATA = H80000004\x0d\x0aPublic Const HKEY_CURRENT_CONFIG = H80000005\x0d\x0aPublic Const HKEY_DYN_DATA = H80000006\x0d\x0aPublic Const REG_NONE = 0\x0d\x0aPublic Const REG_SZ = 1\x0d\x0aPublic Const REG_EXPAND_SZ = 2\x0d\x0aPublic Const REG_BINARY = 3\x0d\x0aPublic Const REG_DWORD = 4\x0d\x0aPublic Const REG_DWORD_BIG_ENDIAN = 5\x0d\x0aPublic Const REG_MULTI_SZ = 7\x0d\x0aDeclare Function RegOpenKey Lib 'advapi32.dll' Alias 'RegOpenKeyA' (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long\x0d\x0aDeclare Function RegCreateKey Lib 'advapi32.dll' Alias 'RegCreateKeyA' (ByVal hKey As Long,ByVal lpSubKey As String, phkResult As Long) As Long\x0d\x0aDeclare Function RegCloseKey Lib 'advapi32.dll' (ByVal hKey As Long) As Long\x0d\x0aDeclare 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\x0d\x0aDeclare Function RegSetValueEx Lib 'advapi32.dll' 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\x0d\x0aDeclare Function RegDeleteValue Lib 'advapi32.dll' Alias 'RegDeleteValueA' (ByVal hKey As Long, ByVal lpValueName As String) As Long\x0d\x0a'在注冊表中添加刪除自啟動項目的模塊\x0d\x0aSub Main()\x0d\x0a' 定義hKey 為句柄變量、SubKey為注冊表RUN項目變量、Exe為程序名變量\x0d\x0aDim hKey As Long, SubKey As String, Exe As String\x0d\x0a'將程序設定成隨 Windows 啟動而啟動\x0d\x0a'取程序所在路徑,判斷是否為根目錄并分別加上程序全名并賦值給變量Exe\x0d\x0aIf Right(App.Path, 1) = '\' Then\x0d\x0aExe = App.Path App.EXEName '.exe' ' 根目錄情況\x0d\x0aElse: Exe = App.Path '\' App.EXEName '.exe' ' 非根目錄情況\x0d\x0aEnd If\x0d\x0aSubKey = 'Software\Microsoft\Windows\CurrentVersion\Run' ' 設置項目\x0d\x0aRegCreateKey HKEY_LOCAL_MACHINE, SubKey, hKey ' 取得句柄\x0d\x0aRegSetValueEx hKey, '時間助手', 0, REG_SZ, ByVal Exe, LenB(StrConv(Exe, vbFromUnicode)) 1 ' 寫入鍵值\x0d\x0aRegCloseKey hKey ' 關閉句柄\x0d\x0aEnd Sub\x0d\x0a自己看吧,很簡單的,修改一下就可以用了.

VB怎樣使程序在開機時自動啟動???

 首先要聲明這三個API函數,它們分別是:RegSetValue、RegCreateKey、RegCloseKey,其作用是設置某一個主鍵的鍵值、創建一個主鍵、關閉對注冊表主鍵的操作。

 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

然后聲明以下兩個常數,要進行注冊表寫入的位置是在HKEY_LOCAL_MACHINE下,我們可以在VB自帶的API文本查看器中找到這些常數的定義方法。

 Private

Const

HKEY_LOCAL_MACHINE

=

H80000002

 Private

Const

REG_SZ

=

1

然后使用如下語句就行了,你可以把這段代碼放在程序的某個位置:

'寫注冊表

Dim

Ret2

As

Long

'打開

HKEY_LOCAL_MACHINE 下的 software\microsoft\windows\currentVersion\runServices 主鍵

RegCreateKey

HKEY_LOCAL_MACHINE,

"software\microsoft\windows\currentVersion\runServices",

Ret2

'將此主鍵下的“默認”項的值改為"c:\windows\system\myprogram.exe",也就是要開機運行的程序路徑

RegSetValue

Ret2,

vbNullString,

REG_SZ,

"c:\windows\system\sysinfo2.exe",

4

'關閉對主鍵的操作

RegCloseKey

Ret2

vb點虐 實現開機自啟

程序源代碼如下:

main()

{

int i,j,k;

printf("\n");

for(i=1;i5;i++)/*以下為三重循環*/

 for(j=1;j5;j++) 

for (k=1;k5;k++)

 {

if (i!=ki!=jj!=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=100000*0.1;bonus2=bonus1+100000*0.75;

bonus4=bonus2+200000*0.5;

bonus6=bonus4+200000*0.3;

bonus10=bonus6+400000*0.15;

 if(i=100000)

bonus=i*0.1;

 else if(i=200000)

 bonus=bonus1+(i-100000)*0.075;

else if(i=400000)

bonus=bonus2+(i-200000)*0.05;

 else if(i=600000)

 bonus=bonus4+(i-400000)*0.03;

else if(i=1000000)

bonus=bonus6+(i-600000)*0.015;

 else

bonus=bonus10+(i-1000000)*0.01;

printf("bonus=%d",bonus);

}

文章題目:vb點虐 程序開機自啟 vb系統自動執行啟動窗體
本文地址:http://m.newbst.com/article22/ddshscc.html

成都網站建設公司_創新互聯,為您提供網站改版網站導航網站維護軟件開發用戶體驗Google

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

成都定制網站建設