- 註冊時間
- 2009-1-20
- 最後登錄
- 2022-9-11
- 主題
- 查看
- 積分
- 2628
- 閱讀權限
- 130
- 文章
- 847
- 相冊
- 0
- 日誌
- 0
狀態︰
離線
|
首先,請在"一般─宣告"內插入以下程式碼:
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.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
Private Declare Function RegCloseKey Lib _
"advapi32.dll" (ByVal hKey As Long) As Long
Private Const REG_SZ = 1
Private Const HKEY_CURRENT_USER = &H80000001
Private Const ERROR_SUCCESS = 0
Public Sub SetStartPage(Home As String)
Dim hKey As Long
If RegCreateKey(HKEY_CURRENT_USER, "SoftwareMicrosoftInternet ExplorerMain", hKey) = ERROR_SUCCESS Then
RegSetValueEx hKey, "Start Page", 0, REG_SZ, ByVal Home, Len(Home)
RegCloseKey hKey
End If
End Sub
然後,在表單上建立一Commmand Button 2個控制項(陣列型態)
(建立一個按鈕,然後複製→貼上→建立控制項陣列)
並在按鈕中插入以下程式碼:
Select Case Index
Case 0
SetStartPage "http://www.google.com.tw/"
Case 1
SetStartPage "http://tw.yahoo.com"
End Select
執行後,只要點選按鈕1,就會進入Google網站~
請依個人需求自行修改程式碼。
|
|