|
|
发表于 2011-10-11 12:59:30
|
显示全部楼层
来自: 中国广东深圳
本帖最后由 yue2233 于 2011-10-14 10:17 编辑 + c! g" ~) ~9 H' r" U
, i4 v* v! C# G4 U
取注册表HKEY_LOCAL_MACHINE\SOFTWARE\Delcam\PowerMILL: l m4 R' r1 L. @/ @; P5 Q
# Z; I% w1 `, y3 `# e5 o N源代码:+ Q3 t/ Q( n' I" d) Z/ ?( L# K
4 D( D1 S7 D, X `
Imports Microsoft.Win32
4 v1 B- ] e) l, R3 E/ S# @. f SPublic Class Form1' |' ^% ]$ Z9 f7 G2 y1 w% n
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
6 Q- w$ O. l( }5 }# K$ I( W- A'查找电脑所有已安装的powermill版本: q; d1 I" N P3 v9 a
Try
( l2 m0 \6 M8 n; W- k/ ? Dim hklm As RegistryKey = Registry.LocalMachine8 R3 v8 @. I- e, B6 Z& A
Dim d As RegistryKey = hklm.OpenSubKey("software\delcam\powermill")
; ]1 K& Q9 N" f; p. F* M Dim s() As String = d.GetSubKeyNames
- I- E ^2 j1 V) o( | For Each obj In s
) v2 R6 U# A3 ?% h/ ?% H'根据查找结果,填充选择框4 R$ M% g& w6 w7 S
Me.ComboBox1.Items.Add(obj)
; ~4 h9 \+ x/ p: Y L Next
; S7 J9 p/ Q; t6 \' h Catch ex As Exception6 B0 U9 k4 a M7 G
End Try. e/ P( G0 y# r
End Sub
: [; Q+ j& c3 r! G( Q
! X I: x4 p& W+ ?0 t'根据选择结果,运行相应版本的powermill. |7 L* _# n; S# x9 _, v
Private Sub ComboBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.TextChanged
( B5 w5 S/ `' c Try
8 r' Q s, K* c. ^7 q7 i* k) M$ d System.Diagnostics.Process.Start(My.Computer.Registry.LocalMachine.OpenSubKey("software\delcam\powermill\" + Me.ComboBox1.Text, False).GetValue("ExecutablePath"))& `. L- ^" x7 p! w# [8 C9 t; i
Catch ex As Exception3 ?/ _1 o) [# p
End Try$ f0 D& P9 s7 v2 P, A6 q5 n+ p0 `
End Sub+ B5 a$ z( r' a
End Class |
|