|
|
发表于 2011-10-11 12:59:30
|
显示全部楼层
来自: 中国广东深圳
本帖最后由 yue2233 于 2011-10-14 10:17 编辑
% F" [( _5 e* d) i& B! l( Z
5 Z; R! r# b6 T6 r' z( A( m+ ?取注册表HKEY_LOCAL_MACHINE\SOFTWARE\Delcam\PowerMILL
' ^8 Z5 d" F3 T' R- E* {/ I C6 f
源代码:9 J! U! J. O- D! A/ T j
! a" m8 Z. x. ~; N; I
Imports Microsoft.Win32
7 a! W3 K% Y/ J0 M2 c c% v5 FPublic Class Form1
6 c, C1 A8 R6 ~% U" f& |8 Q! m Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load9 N) {/ d- Y8 t( Q/ I
'查找电脑所有已安装的powermill版本! H$ d$ P1 H% P4 l
Try9 O* ]! w+ \% N" f
Dim hklm As RegistryKey = Registry.LocalMachine9 J8 V9 i: {$ B+ n; d- i
Dim d As RegistryKey = hklm.OpenSubKey("software\delcam\powermill")
0 G: B" l+ v8 G0 M5 c" @, |: s Dim s() As String = d.GetSubKeyNames- x2 |7 P8 t) {* `! N
For Each obj In s# z4 o# {" C2 A% [8 C3 C
'根据查找结果,填充选择框
, q3 p! B( Z6 k% A Me.ComboBox1.Items.Add(obj)
/ Y2 ^* r0 M( Z6 b' e Next
- G! O" c3 z5 v1 d2 N' z; L Catch ex As Exception P$ U/ `5 b' d* @5 |( J9 M
End Try
4 K4 i: |( O. j6 l5 `& z$ r End Sub4 I1 p# _0 }# g! {
4 n- M- ^$ U6 I+ c. i7 ]
'根据选择结果,运行相应版本的powermill
# F, r, E, d- e0 c4 P Private Sub ComboBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.TextChanged
# f: p% z! X5 T6 V2 a! _ Try. f! V& U) D+ f. z" _ q9 F9 U0 y
System.Diagnostics.Process.Start(My.Computer.Registry.LocalMachine.OpenSubKey("software\delcam\powermill\" + Me.ComboBox1.Text, False).GetValue("ExecutablePath"))5 m! E& m, U% b% h7 w
Catch ex As Exception, m6 v! N# ~/ G1 e. }2 M
End Try) a4 ] U( w5 \' r: J( }3 \
End Sub9 V' h( g Z6 t, ^) |
End Class |
|