Mega Code Archive

 
Categories / Delphi / System
 

[] Windows servislerinin gösterilmesi[hem ad hem görüntü adı]

const SERVICE_KERNEL_DRIVER = $00000001; SERVICE_FILE_SYSTEM_DRIVER = $00000002; SERVICE_ADAPTER = $00000004; SERVICE_RECOGNIZER_DRIVER = $00000008; SERVICE_DRIVER = (SERVICE_KERNEL_DRIVER or SERVICE_FILE_SYSTEM_DRIVER or SERVICE_RECOGNIZER_DRIVER); SERVICE_WIN32_OWN_PROCESS = $00000010; SERVICE_WIN32_SHARE_PROCESS = $00000020; SERVICE_WIN32 = (SERVICE_WIN32_OWN_PROCESS or SERVICE_WIN32_SHARE_PROCESS); SERVICE_INTERACTIVE_PROCESS = $00000100; SERVICE_TYPE_ALL = (SERVICE_WIN32 or SERVICE_ADAPTER or SERVICE_DRIVER or SERVICE_INTERACTIVE_PROCESS); uses WinSvc; // // sMachine: // machine name, ie: \\SERVER // empty = local machine // // dwServiceType // SERVICE_WIN32, // SERVICE_DRIVER or // SERVICE_TYPE_ALL // // dwServiceState // SERVICE_ACTIVE, // SERVICE_INACTIVE or // SERVICE_STATE_ALL // // slServicesList // TStrings variable to storage // function ServiceGetList(sMachine : string;dwServiceType,dwServiceState : DWord; slServicesList : TStrings ): boolean; const cnMaxServices = 4096; type TSvcA = array[0..cnMaxServices] of TEnumServiceStatus; PSvcA = ^TSvcA; var j : integer; schm : SC_Handle; nBytesNeeded, nServices, nResumeHandle : DWord; ssa : PSvcA; begin Result := false; connect to the service control manager schm := OpenSCManager( PChar(sMachine), Nil, SC_MANAGER_ALL_ACCESS); if(schm > 0)then begin nResumeHandle := 0; New(ssa); EnumServicesStatus(schm,dwServiceType,dwServiceState,ssa^[0], SizeOf(ssa^),nBytesNeeded,nServices,nResumeHandle ); for j := 0 to nServices-1 do begin slServicesList. Add( StrPas( ssa^[j].lpDisplayName ) ); // ---------------->>>>>>>>> buraya dikkat edin end; // bu satırdaki "lpDisplayName" direk "Görüntü Adlarını" verir // "lpServiceName" yaparsanız "Servis Adlarını" alırsınız Result := true; Dispose(ssa); CloseServiceHandle(schm); end; end; // KULLANIMINA BİR ÖRNEK ServiceGetList('',SERVICE_WIN32,SERVICE_STATE_ALL,Memo1.Lines); // bütün servisler ServiceGetList('',SERVICE_WIN32,SERVICE_ACTIVE,Memo1.Lines); // çalışan servisler ServiceGetList('',SERVICE_WIN32,SERVICE_INACTIVE,Memo1.Lines); // durgun servisler