|
|
发表于 2011-10-11 12:59:30
|
显示全部楼层
来自: 中国广东深圳
本帖最后由 yue2233 于 2011-10-14 10:17 编辑 / X2 J7 g$ y. ~+ ~$ d" T5 R
+ j0 B: N# @& i/ u- T; U* W
取注册表HKEY_LOCAL_MACHINE\SOFTWARE\Delcam\PowerMILL
* i$ d& J- T! G5 h* o! P: V8 O$ i1 w- S o
源代码:
* n! H6 `( \* n8 ~$ `8 U% h
2 Z: m$ a* y8 U, A2 g0 hImports Microsoft.Win32
& S( x' [6 X7 T' y3 x8 I0 ~* ]* Z; t$ iPublic Class Form1. N# p4 v6 _' D2 H( K
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
4 x" b" ?, `& F. H'查找电脑所有已安装的powermill版本. v, Q, S. }: V
Try
0 F: }" K0 Q( U" x* n Dim hklm As RegistryKey = Registry.LocalMachine6 ^6 f+ ^5 D7 ~3 ?: X
Dim d As RegistryKey = hklm.OpenSubKey("software\delcam\powermill")
/ U6 F9 ?) U7 }1 x Dim s() As String = d.GetSubKeyNames
( \+ r/ z: Y; C( Y5 D/ U For Each obj In s, K8 h: l# ]# S+ o0 D. r8 ~( \
'根据查找结果,填充选择框, L9 D' f4 J; t
Me.ComboBox1.Items.Add(obj)% Y* {; e) \4 M1 g" U2 A1 H- e0 y+ X
Next( p( W7 r z5 _+ _
Catch ex As Exception
3 O5 c5 q9 `/ n. W* q End Try' j o9 ^1 B/ D$ P! E' B
End Sub+ Z4 y0 V' l# _/ {- M- K+ B
! c& \# K1 n4 u+ I( s; C- P
'根据选择结果,运行相应版本的powermill
5 Q$ Z9 J ~- k4 W5 Q Private Sub ComboBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.TextChanged8 Z' q2 C1 @. e' N3 l( G
Try2 E4 R- k. K8 T* s' H% a+ e/ T3 v0 T
System.Diagnostics.Process.Start(My.Computer.Registry.LocalMachine.OpenSubKey("software\delcam\powermill\" + Me.ComboBox1.Text, False).GetValue("ExecutablePath"))
/ T! U5 E- z- \2 b; z) n6 y Catch ex As Exception$ a4 h& }" g* a0 E+ b$ @
End Try; H7 G" E G9 x L0 @: c7 g: G
End Sub: m2 G$ \( C7 @
End Class |
|