using Microsoft.Win32;
public string FindWinrar(){
string winrarPath= string.Empty;
RegistryKey key = Registry.LocalMachine;
//加载x86路径:在64bit系统中,x86程序注册在Wow6432Node下。
RegistryKey key32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
//加载x64路径:在64bit系统中,x64程序在原路径节点下。
RegistryKey key64 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
RegistryKey subkey = key.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\App Paths\winrar.EXE", true);
//获得WINRAR路径
if (subkey != null)
winrarPath = subkey.GetValue("Path");
else
winrarPath = My.Computer.Registry.GetValue(@"HKEY_CURRENT_USER\Software\WinRAR SFX", "C%%Program Files (x86)%WinRAR", string.Empty);
return winrarpath;
//string[] subKeyNames = spfKey.GetSubKeyNames()
}
using System;
using Microsoft.Win32;
public class GetDotNetVersion
{
public static void Main()
{
Console.WriteLine(".NET框架版本:");
using (RegistryKey ndpKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, "").OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\"))
{
foreach (string versionKeyName in ndpKey.GetSubKeyNames())
{
if (versionKeyName.StartsWith("v"))
{
RegistryKey versionKey = ndpKey.OpenSubKey(versionKeyName);
string name = (string)versionKey.GetValue("Version", "");
string sp = versionKey.GetValue("SP", "").ToString();
string install = versionKey.GetValue("Install", "").ToString();
if (install == "") //no install info, ust be later
Console.WriteLine(versionKeyName + " " + name);
else
{
if (sp != "" && install == "1")
{
Console.WriteLine(versionKeyName + " " + name + " SP" + sp);
}
}
if (name != "")
{
continue;
}
foreach (string subKeyName in versionKey.GetSubKeyNames())
{
RegistryKey subKey = versionKey.OpenSubKey(subKeyName);
name = (string)subKey.GetValue("Version", "");
if (name != "")
sp = subKey.GetValue("SP", "").ToString();
install = subKey.GetValue("Install", "").ToString();
if (install == "") //no install info, ust be later
Console.WriteLine(versionKeyName + " " + name);
else
{
if (sp != "" && install == "1")
{
Console.WriteLine(" " + subKeyName + " " + name + " SP" + sp);
}
else if (install == "1")
{
Console.WriteLine(" " + subKeyName + " " + name);
}
}
}
}
}
}
Console.WriteLine();
Console.WriteLine("操作系统版本:" + System.Environment.OSVersion.ToString());
Console.WriteLine("当前.NET框架版本:" + System.Environment.Version.ToString());
Console.ReadKey();
}
}
Imports Microsoft.Win32
Imports System.Windows.Forms
Dim dialog As New Microsoft.Win32.FolderBrowserDialog
If dialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
string txt = dialog.SelectedPath
End If
Dim dialog1 As New System.Windows.Forms.OpenFileDialog
dialog1.InitialDirectory = "C:\"
dialog1.Filter = "JPG|*.jpg|TIF|*.tif|BMP|*.bmp|DOC|*.doc|TXT|*.txt|RTF|*.rtf|PDF|*.pdf|XLS|*.xls|*|*.*"
dialog1.FilterIndex = 1
If dialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
string txt = dialog1.FileName
End If