|
|
发表于 2011-10-11 12:59:30
|
显示全部楼层
来自: 中国广东深圳
本帖最后由 yue2233 于 2011-10-14 10:17 编辑 # y. Z! i! |; }. Q
+ D$ b0 H0 U0 i+ [7 u
取注册表HKEY_LOCAL_MACHINE\SOFTWARE\Delcam\PowerMILL
9 h9 b* j; S- }' ~8 F t r5 ?! q; [) J( r: m$ A& z& M
源代码:
3 n% f: i! R% l/ A: _
/ f; Q1 ^8 R# \. P* l* F, f" k! _Imports Microsoft.Win32
! W' ~8 Q4 S4 y4 n" a' ]1 X# IPublic Class Form1
) U9 h& t: U% U% P$ C Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
2 C5 I+ |6 \" V+ q* s( N'查找电脑所有已安装的powermill版本; N; v% f+ S# ] `/ B5 V+ F
Try
; d7 U; h& `' ]* p0 D- c Dim hklm As RegistryKey = Registry.LocalMachine$ S& R# _) T' i* P; y2 C# w
Dim d As RegistryKey = hklm.OpenSubKey("software\delcam\powermill")4 z/ F' h6 m2 v. F
Dim s() As String = d.GetSubKeyNames( D0 {+ S" { d: ]8 D
For Each obj In s3 [+ e0 G. j, i8 ~& g
'根据查找结果,填充选择框
# R/ H+ L0 x$ W: W% i Me.ComboBox1.Items.Add(obj)
% U- K/ Y% U. q" S, T% d Next, A, Q$ u0 K5 p$ s+ Z& G. f
Catch ex As Exception" a6 N9 a( w* S \* B$ G$ F( z
End Try
; y5 y, p' o6 w. _ End Sub
; `/ X x3 I# m) H8 R
9 h, U% W+ v( m: |! O+ k; m+ Y& ?'根据选择结果,运行相应版本的powermill. Q& g. ~+ U0 Q* q3 s- m+ @+ a
Private Sub ComboBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.TextChanged
' G4 V; T& }. c5 c2 L Try
4 O6 y2 l! n K5 I9 e: F System.Diagnostics.Process.Start(My.Computer.Registry.LocalMachine.OpenSubKey("software\delcam\powermill\" + Me.ComboBox1.Text, False).GetValue("ExecutablePath"))" y+ Q. F- q8 D& `# K
Catch ex As Exception) E% _( q) K) g6 W1 K
End Try
3 [5 y e2 u; C: \6 G End Sub, r: |: G5 s5 B; e# X
End Class |
|