التنبيهات التالية ظهرت :
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 864 - File: showthread.php PHP 7.4.33 (Linux)
File Line Function
/showthread.php 864 errorHandler->error



تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
استرجاع جميع السيرفس services في الجهاز التي تكون في حاله running C# و vb.net
#1
كاتب الموضوع : AhmedEssawy

اولا يجب عليك اضافه

كود :
[FONT=Courier New][color=blue][COLOR=blue][FONT=Courier New]using[/FONT][/color][FONT=Courier New][color=#000000] System.ServiceProcess ;[/color][/FONT][/COLOR][/FONT]


و اضافه system.serviceprocess.dll في refrence المشروع




C#



كود :
[FONT=Courier New][color=blue][FONT=Courier New]private[/FONT][/color][FONT=Courier New][color=blue]void[/color][color=#000000] button1_Click([/color][color=blue]object[/color][color=#000000] sender, [/color][color=teal]EventArgs[/color][color=#000000] e)[/color][/FONT][/FONT]


[FONT=Courier New][FONT=Courier New][color=#000000]{[/color][/FONT][/FONT]


[FONT=Courier New][FONT=Courier New][color=teal]ServiceController[/color][color=#000000][] scServices;[/color][/FONT][/FONT][FONT=Courier New]


[FONT=Courier New][color=#000000]scServices = [/color][color=teal]ServiceController[/color][color=#000000].GetServices();[/color][/FONT]



[FONT=Courier New][color=green]// Display the list of services currently running on this computer.[/color][/FONT]



[FONT=Courier New][color=teal]MessageBox[/color][color=#000000].Show([/color][color=maroon]"Services running on the local computer:"[/color][color=#000000]);[/color][/FONT]


[FONT=Courier New][color=blue]foreach[/color][color=#000000] ([/color][color=teal]ServiceController[/color][color=#000000] scTemp [/color][color=blue]in[/color][color=#000000] scServices)[/color][/FONT]


[FONT=Courier New][color=#000000]{[/color][/FONT]


[FONT=Courier New][color=blue]if[/color][color=#000000] (scTemp.Status == [/color][color=teal]ServiceControllerStatus[/color][color=#000000].Running)[/color][/FONT]


[FONT=Courier New][color=#000000]{[/color][/FONT]


[FONT=Courier New][color=green]// Write the service name and the display name[/color][/FONT]


[FONT=Courier New][color=green]// for each running service.[/color][/FONT]



[FONT=Courier New][color=teal]MessageBox[/color][color=#000000].Show([/color][color=maroon]" Service : "[/color][color=#000000] + scTemp.ServiceName);[/color][/FONT]


[FONT=Courier New][color=teal]MessageBox[/color][color=#000000].Show([/color][color=maroon]" Display name: "[/color][color=#000000] + scTemp.DisplayName);[/color][/FONT]




[FONT=Courier New][color=#000000]}[/color][/FONT]


[FONT=Courier New][color=#000000]}[/color][/FONT]




[FONT=Courier New][color=#000000]}[/color][/FONT]



[/FONT]


vb



كود :
[FONT=Courier New][color=blue][FONT=Courier New]Dim[/FONT][/color][FONT=Courier New][color=#000000] scServices() [/color][color=blue]As[/color][color=#000000] ServiceController[/color][/FONT][/FONT]


[FONT=Courier New][FONT=Courier New][color=#000000]scServices = ServiceController.GetServices()[/color][/FONT][/FONT][FONT=Courier New]



[color=green][FONT=Courier New]' Display the list of services currently running on this computer.[/FONT][/color]


[FONT=Courier New][color=#000000]Console.WriteLine([/color][color=maroon]"Services running on the local computer:"[/color][color=#000000])[/color][/FONT]



[color=blue][FONT=Courier New]Dim[/FONT][/color][FONT=Courier New][color=#000000] scTemp [/color][color=blue]As[/color][color=#000000] ServiceController[/color][/FONT]


[color=blue][FONT=Courier New]For[/FONT][/color][FONT=Courier New][color=blue]Each[/color][color=#000000] scTemp [/color][color=blue]In[/color][color=#000000] scServices[/color][/FONT]



[FONT=Courier New][color=blue]If[/color][color=#000000] scTemp.Status = ServiceControllerStatus.Running [/color][color=blue]Then[/color][/FONT]


[color=green][FONT=Courier New]' Write the service name and the display name[/FONT][/color]


[color=green][FONT=Courier New]' for each running service.[/FONT][/color]


[FONT=Courier New][color=#000000]Console.WriteLine()[/color][/FONT]


[FONT=Courier New][color=#000000]Console.WriteLine([/color][color=maroon]" Service : {0}"[/color][color=#000000], scTemp.ServiceName)[/color][/FONT]


[FONT=Courier New][color=#000000]Console.WriteLine([/color][color=maroon]" Display name: {0}"[/color][color=#000000], scTemp.DisplayName)[/color][/FONT]




[FONT=Courier New][color=blue]End[/color][color=blue]If[/color][/FONT]



[color=blue][FONT=Courier New]Next[/FONT][/color][FONT=Courier New][color=#000000] scTemp[/color][/FONT]

[/FONT]
[/font]
}}}
تم الشكر بواسطة:


الردود في هذا الموضوع
استرجاع جميع السيرفس services في الجهاز التي تكون في حاله running C# و vb.net - بواسطة Raggi Tech - 17-10-12, 04:46 PM

المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  كيف تكون مجلد جديد RaggiTech 0 2,210 17-10-12, 09:22 PM
آخر رد: RaggiTech
  عمل Copy-Paste من صوره على الجهاز الى البرنامج RaggiTech 0 2,475 17-10-12, 08:56 PM
آخر رد: RaggiTech
  - بعيداً عن إستخدام الـ Icons أقدم لكم الخط -Webdings- لإنشاء الأيكونات التي تفضلها - RaggiTech 0 1,905 17-10-12, 08:17 PM
آخر رد: RaggiTech
  نسخ مجلد مع جميع محتوياته RaggiTech 0 2,107 17-10-12, 06:49 PM
آخر رد: RaggiTech
  معرفة حجم مجلد مع جميع الملفات و المجلدات التي يحتوي عليها باستعمال ال Recursion RaggiTech 0 2,181 17-10-12, 06:47 PM
آخر رد: RaggiTech
  معرفة العنوان الفيزيائي لكروت الشبكة المثبة على الجهاز RaggiTech 0 2,346 17-10-12, 06:47 PM
آخر رد: RaggiTech
  لمعرفة نسخة الفريم وورك التي يعمل عليها التطبيق RaggiTech 0 1,688 17-10-12, 06:18 PM
آخر رد: RaggiTech
  لمعرفة الطابعات المثبة على الجهاز RaggiTech 0 1,877 17-10-12, 06:15 PM
آخر رد: RaggiTech
  لحذف جميع العناصر المختارة في ListBox RaggiTech 0 2,041 17-10-12, 06:06 PM
آخر رد: RaggiTech
  كيفية عمل Restore Point مع جميع خصائصه باستعمال دوال ال API RaggiTech 0 2,058 17-10-12, 06:00 PM
آخر رد: RaggiTech

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم