???? ID: 816169 - ????? ???????: 30 ??????? 2010 - ??????: 4.0
Windows ???? ?? ???? ????????? ?? ??? ?? ????? ????????? ????? ??? ????? C# ???? ????
?????? ?????? This article applies to a different operating system than the one you are using. Article content that may not be relevant to you is disabled.
?? ???? ????? ???? ?? (formerly ???? ?? "NT ????") Windows ???? ????????? ?? ??? ?? ????? ????????? ????? ?? ??? ???? ????? ??? ???? ?? ???, ???? ???? ????? ???? ?? ?? ?????? Windows ???? ??? ??? ?????? ????????? ?? ???? ????????? ??? ????????? ????? ??? ?? ?? ????? ??? ????? ????????? ????? ???? ?? ??????? ???? ?? ??? ?????? ???? ?? ???? ???, ?? ???? ???????? ?? ??????? ???? ??? ???????????? ????? ?????? ??? ???? ???? ?? ????? ?? ???? ??????? ?? ???? ????
??????????????? ???? outlines ???????? ?????????, ??????????, ??????? ??????, ?? ???? ??? ?????? ???? ???:
Microsoft Windows 2000, Windows XP, Windows Server 2003, ?? ??? .NET Framework ??????? ???? ?? ??? ??? Microsoft ???????? ?????? Microsoft Visual Studio .NET ??????????, Microsoft Visual Studio .NET ?????????? ??????????, Microsoft Visual Studio 2005 ?? Microsoft Visual Studio 2008? ?? ???? ????? ?? ?? ?? Windows ?????? ?? ?????? ???? ??? ?? Windows ?????? ?? ?????? ???? ???, ???? ?????? ??? ?????
?????? ?? ???? ?? ????
?? ???? ?? ????? ?? ?????????? ???? ???? ?? ??????? ???? ?? ??? ?? ?? ???? ?? ????? ?? ??? ????? ????????? ?? ??????? ???? ?? ??? ?? ?????? ??????? ???? ?? ??? ???? ?????? ??, ?? ????? ??? ??? ?????? ???? ?? ??? ???? ??? ?????? ????????? ?? ?? ???
??? ????? ????????? ?? ???? Windows ???? ?? ??? ??????? ??? ????? ?? ?? ???? Windows ?? ???? ???? ?? ????? ?? ??? ?????????, ?? Windows ???? ?? ??????? ???? ?? ??? ??? ?????? ????? ????????? ?? ????? ???? ?????
???? Windows ???? ????????? ?????Microsoft Visual Studio ??????? ????? ????? ???????? ???? ??,??? ?? ????-????? ????, ?? ???? ???????????? . ????? ????,????? C# ????????? ?? ???????????????? ?????? ?? ????-????? ????, ?? ???? ???Windows ???? ?? ??????????????? .???: Visual Studio 2005 ?? Visual Studio 2008, ??? ??????? ????????? C# ?? ???????????????? ?????? ????? ????,Windows ?? ????-????? ????, ?? ???? ???Windows ???? ?? ??????????????? . ??????:LogWriterService ???????? ??? ????? ???, ?? ???? ??? ??????C:\ ?????????? ??? ????? ???? ????? ????,OK . ?????? Explorer ???, ???? ?????Service1.cs ?? ????-????? ????, ?? ???? ???????? ??? . ?????OnStart ????? ??????, ?????????? ?? ????? ??? ?? ???????????? ????:EventLog.WriteEntry("My simple service started."); ?????? Explorer, ??? ??? ????? ????Service1.cs . ??? ?????? ????? ??? ???? ??????????? ????? ?? ????-????? ????, ?? ???? ?????? ??? ??? ??? ????? ??????????? ?????? ????. ?? ??? ??? ??? ???ServiceInstaller1 , ????????? ????ServiceName ???? ?? ??? ???Service1 . ?????? ????? ??? ??? ?????? ?????, ??? ????? ????ServiceProcessInstaller1 . ??? ??? ???, ??? ????????? ???? ?? ??? ???LocalSystem (LocalService , ??NetworkService ??? ??? ???? Windows XP ??? ?????? ??)? Windows ???? ?? ??????? ???? ?? ??? ??? ?????? ????? ????????? ?? ????? ????Windows ?????? ????????? ?? ???????? ???? ?? ??? ????? ?????? ??? ??? ???? ???? ?? ??? ????????? ????????? ?? ?? ???? ????????? ??????? ???? ?? ???? ???? ????????? ?? ???????? ?? ?????? ?? ???, ????? ????? ?? ???? ????:
???? LogWriterService ????????? ?? ??? ??? ??? ????????? ??????? ??? ???? ?? ???, ????? ????? ?? ???? ????::?????? Explorer ???, ???? ??????????? 'LogWriterService' (1 ?????????) ?? ????? ????,add ?? ????-????? ????, ?? ???? ?????? ????????? . ????? ????,????? ?? ????????? ????????? ?? ???????????????? ?????? ?? ????-????? ????, ?? ???? ???????? ????????? ?? ??????????????? . ???????? ??? ????? ???, ??????ServiceSetup . ??????:C:\ ?????????? ??? ????? ???, ?? ???? ???OK . ????? ????????? ????????? ???? ????? ???? ?? ???? ??? ???? ?? ???, ????? ????? ?? ???? ????::?????? Explorer ???, ???? ?????ServiceSetup ?? ????? ????,add ?? ????-????? ????, ?? ???? ???????????? ?????? ?????????????? ?????? ???? ?????? ????? ?????, ???????????? ????? ???, ????? ????LogWriterService ????? ????,???????? ?????? ?? ????-????? ????, ?? ???? ???OK . ??? ??????? ?? ??? ???? ???????? ?????? ??? ?????? ????? ?????? ??????, ?? ????? ?? ???? ????:?????? Explorer ???, ???? ?????ServiceSetup ?? ????? ????,????? ?? ????-????? ????, ?? ???? ???????? ?????? ????-????? ????????? ?????? ?? ????-????? ????, ?? ???? ???????? ?????? ?????? . ????? ????,????????? ??????? ?? ????-????? ????, ?? ???? ???OK . ????? ????,LogWriterService ?? ???????? ?????? (??????) ?? ????-????? ????, ?? ???? ???OK . ?? ????????????? ?????? ?? ??????? ????? ???? ????????? ???? ,???? ,?????? , ????????? ???? ???? . ???????? ??? ??, ????? ??????????? ??? ??? ????? ???? ????? ???????????? ?????? ?????, ????? ??????? ??? ?? ???? ?? ?? ?????:?????? 1: ????-????? ????LogWriterService ?? ????-????? ????, ?? ???? ???????? . ????-????? ????ServiceSetup ?? ????-????? ????, ?? ???? ???????? . ???? 2 ????? ????????? ???? ??,??????????? ??????? ???? ?????? ????? ??? ?? ??? ???? ?? ??? ????? ????????? ServiceSetup ?? ??? ????? ??? ????? ???? ?????? ????? ?? ??? F7 ?????? ?????? ????? ??, ?? ???? ??? ????? ??????? ?????? ?? ?? ???? ?? ??? ?????? ??? ?? ?????????? ???? ?? ??????? ???? ?? ??? ???? ?????ServiceSetup ?? ????-????? ????, ?? ???? ?????????? ???? . ?????ServiceSetup ????? ????? ???, ????? ????next ??? ???? ????? ??? ?? ???? ??????? ???? ??? ??? ?????? ????? ????? ??? ?? ???? ??????? ??, ????? ??????? ???? . ??? ??????? ?????Service1.cs using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
namespace LogWriterService
{
public class Service1 : System.ServiceProcess.ServiceBase
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Service1()
{
// The Windows.Forms Component Designer must have this call.
InitializeComponent();
// TODO: Add any initialization after the InitComponent call
}
// The main entry point for the process
static void Main()
{
System.ServiceProcess.ServiceBase[] ServicesToRun;
// More than one user service may run in the same process. To add
// another service to this process, change the following line to
// create a second service object. For example,
//
// ServicesToRun = New System.ServiceProcess.ServiceBase[] {new Service1(), new MySecondUserService()};
//
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new Service1() };
System.ServiceProcess.ServiceBase.Run(ServicesToRun);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.ServiceName = "Service1";
}
/// <summary>
/// Clean up any resources that are being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
/// <summary>
/// Set things in motion so your service can do its work.
/// </summary>
protected override void OnStart(string[] args)
{
EventLog.WriteEntry("My simple service started.");
}
/// <summary>
/// Stop this service.
/// </summary>
protected override void OnStop()
{
// TODO: Add code here to perform any tear-down necessary to stop your service.
}
}
} ???? ???? ?? ??? ??????????? ???? ??? ??? ????? ???????????????? ????? ????? ????, ?? ???? ????????? ????-????? ????Service1 ?? ????-????? ????, ?? ???? ?????????? ???????? ???? ?? ????? ??? ??? ????? ??? ?? ???? ?? ??? ?? ????? ??????? ?? ????? ????:?????? 1: ???????? ???? ??? ??? ????? ???????????????? ????? ????? ????, ?? ???? ???????? ?????? . ????? ????,????????? ??? ???? ??? ???, ?? ???? ??? ???? ??? ?? ???? ???? ?? ??? ????? ??? ?? ?????? ?????? ???? 2 ????? Explorer ???, ??????? ????????? , ??????? ????ComputerName , ??????? ????????? ????? , ??????? ????????????? , ?? ???? ??? ??????? ????Service1 .
?? ???? ????Service1 ????, ???? ???? ?? ??? ?? ?????? ?????,Service1 ????????? ??? ?? ??? ??? ????? ???? ???
(?? ?? ?????? ????? ?? ???????? ???? ?? ??? ?? ???? ?? ????? ?? ???? ??.) ????? ?? ??? ???????????? ?? ??? ?? ????? ??? ?? ????? ????????? ?? ??? "???? ?????? ???? ??????? ????" ????? ???? ?????? ?????? ??????Framework SDK ???????? ????? ????? ??:
????????? meaningful ????? ?? ????? ?? ???? ???? ???? ?? ?????? ???????? ????? ????? ???? ???? ????????? ????????? ????? ?? ?? ?? ????? ?? ??????? ???? ?????? ??? ?? ???? ???? ?? F5 ?? F11 ??? ?? ???? ???? ????????? ?? ????? ???? ?? ????; ???? ????? ????? ???? ?? ??? ??? ???? ???? ???? ????, ?? ?????? ??????? ?? ???? ???? ??????? ????, ?? ?? ???? ?? ????????? ??? ????? ??????? ?????
???? ??????? ?? ???, ????? Microsoft ?????? ??????? (MSDN) ??? ???? ?? ????::
????? ?? ??? ?? ?????? Windows ???? ?? ?? ?? ????????? ???? ?? ?? ???? ??????? ???? ?? ???, ?? ??????? ???? ???? ?? ???? ???? ???? ???? ?? ???, ????? MSDN ??? ???? ?? ????:
???? ??????? ?? ??? MSDN Magazine ?? ?????? 2001 ?????? ?? ?????????? ???? ?????:
???? ???? ???? ??: Microsoft Visual C# .NET 2003 Standard Edition Microsoft Visual C# 2005 Express Edition Microsoft Visual C# 2008 Express Edition kbeventlog kbsetup kbserviceprocess kbservice kbhowtomaster kbmt KB816169 KbMthi
???? ?????? ???????? ??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:
816169
(http://support.microsoft.com/kb/816169/en-us/
)
Was this information helpful?
How much effort did you personally put forth to use this article?
Tell us why and what can we do to improve this information
Thank you! Your feedback is used to help us improve our support content. For more assistance options, please visit the
Help and Support Home Page .
???? ?????? ???? ?????? ??????
??????
??? ?????? ??????? ????
???? ??????