1. Trang chủ
  2. » Công Nghệ Thông Tin

Chapter 2: Creating and managing Windows services - Nguyễn Đức Cương

46 36 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 46
Dung lượng 1,19 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Chapter 2: Creating and managing Windows services includes understanding Windows services; creating Windows services; handling events and logging information from a Windows services application; adding installers, specifying security context and installing and uninstalling a Windows services.

Trang 1

! "# $ %&

Trang 5

 The Services window of the Administrative Tools component  5

Trang 10

,

Trang 15

  The Visual Studio NET New Project dialog box B5

Trang 20

protected override void OnStart(string[] args)

StreamWriter sr = new StreamWriter(fs);

protected override void OnStop()

Trang 25

  5

private System.Diagnostics.EventLog eventLog1;

private void CreateEventLog()

{ eventLog1 = new System.Diagnostics.EventLog();

Trang 34

!    & '

See Text Book page 77-82

Trang 35

  .5

Trang 36

$

Trang 37

  .8

, (

Trang 40

      #  

( ( +

!

private ServiceController serviceCtr1;

this.serviceCtr1 = new ServiceController();

this.serviceCtr1.MachineName = “.";

this.serviceCtr1.ServiceName = "DBWriter";

Trang 44

if(System.DateTime.Now.Hour <= 24 )

MyServiceController.ExecuteCommand(220);

}

Trang 45

  05

protected override void OnCustomCommand(int command)

{ FileStream FS = new FileStream(@"c:\MyWindowsService_CSharp.txt",

SR.WriteLine("Good Everning");

SR.Flush();

} }

Trang 46

J !

static void Main(string[] args)

{ ServiceController MyServiceController = new ServiceController(); ServiceController[] services= ServiceController.GetServices(); IEnumerator enumerator = services.GetEnumerator();

while (enumerator.MoveNext())

{

Console.WriteLine(((ServiceController)_

enumerator.Current).ServiceName); }

Console.WriteLine("Press <Enter> to exit");

Console.Read();

... class="page_container" data-page="45">

  05

protected override void OnCustomCommand(int command)

{ FileStream FS = new FileStream(@"c:\MyWindowsService_CSharp.txt",... 36

$

Trang 37

  .8

,... 44

if(System.DateTime.Now.Hour <= 24 )

MyServiceController.ExecuteCommand(220);

}

Ngày đăng: 30/01/2020, 04:22