74 lines
2.4 KiB
C#
74 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
//using System.Linq;
|
|
using System.Text;
|
|
using Microsoft.Win32;
|
|
namespace HiiShe.Manager
|
|
{
|
|
class PrintHelper
|
|
{
|
|
#region 注册表操作
|
|
/// <summary>
|
|
/// 将值写入注册表
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
/// <param name="value"></param>
|
|
public static void WriteRegedit(string name, string value)
|
|
{
|
|
RegistryKey hkcu = Registry.CurrentUser;
|
|
RegistryKey software = hkcu.OpenSubKey("SOFTWARE", true);
|
|
RegistryKey SuperMap = software.OpenSubKey("SuperMap", true);
|
|
if (SuperMap == null)
|
|
SuperMap = software.CreateSubKey("SuperMap");
|
|
RegistryKey SuperMapFloor = SuperMap.OpenSubKey("SuperMap PrintCommodity", true);
|
|
if (SuperMapFloor == null)
|
|
SuperMapFloor = SuperMap.CreateSubKey("SuperMap PrintCommodity");
|
|
|
|
SuperMapFloor.SetValue(name, value, RegistryValueKind.String);
|
|
|
|
SuperMapFloor.Close();
|
|
SuperMap.Close();
|
|
software.Close();
|
|
hkcu.Close();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 向注册表获取值
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
/// <returns></returns>
|
|
public static string GetRegistData(string name)
|
|
{
|
|
string registData = "0,0,0,0,0,0,0,0,0,0,0,0,0,0";
|
|
RegistryKey hkml = Registry.CurrentUser;
|
|
RegistryKey software = hkml.OpenSubKey("SOFTWARE", true);
|
|
RegistryKey SuperMap = software.OpenSubKey("SuperMap", true);
|
|
|
|
if (SuperMap == null)
|
|
{
|
|
software.CreateSubKey("SuperMap");
|
|
}
|
|
|
|
RegistryKey SuperMapFloor = SuperMap.OpenSubKey("SuperMap PrintCommodity", true);
|
|
if (SuperMapFloor == null)
|
|
registData = "0,0,0,0,0,0,0,0,0,0,0,0,0,0";
|
|
else
|
|
{
|
|
object _Value = SuperMapFloor.GetValue(name);
|
|
if (_Value == null)
|
|
registData = "0,0,0,0,0,0,0,0,0,0,0,0,0,0";
|
|
else
|
|
registData = _Value.ToString();
|
|
SuperMapFloor.Close();
|
|
}
|
|
|
|
SuperMap.Close();
|
|
software.Close();
|
|
hkml.Close();
|
|
|
|
return registData;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|