动态创建空间
Dim pTool As ToolStrip = New ToolStrip()
pTool.SendToBack()
Controls.Add(pTool)
或
Dim pBtn As ToolStripButton = New ToolStripButton
pBtn.TextAlign = ContentAlignment.MiddleRight
pBtn.ImageAlign = ContentAlignment.MiddleLeft
pBtn.Text = pCmd.Caption
If pCmd.Bitmap <> 0 Then
pBtn.Image = System.Drawing.Image.FromHbitmap(pCmd.Bitmap)
End If
BtnStrip.Items.Add(pBtn)
AddHandler pBtn.Click, AddressOf Me.CommandClick
或
Type.GetType("System.Windows.Forms.CheckBox, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
动态使用字符串创建变量
Dim pCmd As ICommand
Dim ctlType As Type = Type.GetType(pCls)
If Not ctlType Is Nothing Then
pCmd = CType(System.Activator.CreateInstance(ctlType), ICommand)
end if
注册表操作
Microsoft.Win32
Registry.ClassesRoot 对应于HKEY_CLASSES_ROOT子目录树
Registry.CurrentUser 对应于HKEY_CURRENT_USER子目录树
Registry.LocalMachine 对应于 HKEY_LOCAL_MACHINE子目录树
Registry.User 对应于 HKEY_USER子目录树
Registry.CurrentConfig 对应于HEKY_CURRENT_CONFIG子目录树
Registry.DynDa 对应于HKEY_DYN_DATA子目录树
Registry.PerformanceData 对应于HKEY_PERFORMANCE_DATA子目录树
Dim hklm As RegistryKey = Registry.LocalMachine
Dim software11 As RegistryKey = hklm.OpenSubKey ( "SYSTEM" ) '打开"SYSTEM"子健
Dim software As RegistryKey = software11.OpenSubKey ( "A000" ) '打开"A000"子健
Dim software11 As RegistryKey = hklm.OpenSubKey ( "SYSTEM" ,true ) '打开"SYSTEM"子健
Dim software As RegistryKey = software11.OpenSubKey ( "A000" , true ) '打开"A000"子健
Dim ddd As RegistryKey = software.CreateSubKey ( "ddd" )
ddd.SetValue ( "www" , "1234" )
Dim KeyCount As integer = software.SubKeyCount '获得当前健下面有多少子健
Dim Str ( ) As String = software.GetSubKeyNames ( ) '获得当前健下面所有子健组成的字符串数组
Dim Str2 ( ) As String = sitekey.GetValueNames ( ) '获得当前子健下面所有健组成的字符串数组
Dim ValueCount As integer = sitekey.ValueCount '获得当前子健存在多少健值
快速结束当前应用程序
Private Declare Sub ExitProcess Lib "kernel32" (ByVal uExitCode As Long)
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
ExitProcess GetExitCodeProcess(GetCurrentProcess, 0)
ShellExe
Dim LngHandle As Long
LngHandle = FindWindow(vbNullString, "供电范围颜色.")
If LngHandle > 0 Then
BringWindowToTop (LngHandle)
ShowWindow LngHandle, 5
Exit Sub
End If
Shell "SysColors.exe", vbNormalFocus