winform中服务程序的制作
winform中服务程序的制作的步骤和注册到Windows注册表的方法
------解决方案--------------------windows服务自己从网上找个sample
注册表操作,给你一点代码参考
///// <summary>
///// 注册表中写入程序的运行路径
///// </summary>
///// <param name= "FilePath "> </param>
///// <param name= "ProgrameName "> </param>
private static void ReigsterProgramePath(string FilePath, string ProgrameName, string CurrentVersion,string RestartTime)
{
RegistryKey _RegisterKey = Registry.LocalMachine;
RegistryKey _SubKey = _RegisterKey.CreateSubKey(@ "SOFTWARE\自己公司名\ " + ProgrameName);
_SubKey.SetValue( "Watch ", "true ");
_SubKey.SetValue( "ProgramName ", ProgrameName + ".exe ");
_SubKey.SetValue( "CurrentVersion ", CurrentVersion);
_SubKey.SetValue( "InstallPath ", FilePath);
_SubKey.SetValue( "RestartTime ", RestartTime);
_SubKey.Close();
_RegisterKey.Close();
}
/// <summary>
/// 删除对应的注册值
/// </summary>
/// <param name= "ProgrameName "> </param>
private static void UnReigsterProgramePath(string ProgrameName)
{
RegistryKey _RegisterKey = Registry.LocalMachine;
RegistryKey _Key = _RegisterKey.CreateSubKey(@ "SOFTWARE\自己公司名 ");
_Key.DeleteSubKey(ProgrameName);
_Key.Close();
_RegisterKey.Close();
}