Ingin tau mencari status dari ServiceWindows ?
gunakan fungsi "QueryServiceStatus()"
gunakan fungsi "QueryServiceStatus()"
Caranya adalah sebagai berikut:
Naahh.....
saat ini kita punya fungsi dasar -- "ServiceGetStatus()" -- untuk mendapat status dari service yang berjalan pada mesin tertentu, mari kita sederhanakan proses dengan menggunakan fungsi: "ServiceRunning()" and "ServiceStopped()"
Baik "ServiceRunning()" maupun "ServiceStopped()" membutuhkan nama mesin dan nama service. Nama Mesin dapat dikosongkan jika yang diuji adalah mesin lokal.
Contohnya:
uses WinSvc; //------------------------------------- // get service status // return status code if successful -1 if not // return codes: // SERVICE_STOPPED // SERVICE_RUNNING // SERVICE_PAUSED // SERVICE_START_PENDING // SERVICE_STOP_PENDING // SERVICE_CONTINUE_PENDING // SERVICE_PAUSE_PENDING // sMachine: // machine name, ie: \SERVER // empty = local machine // sService // service name, ie: Alerter function ServiceGetStatus( sMachine, sService : string ) : DWord; var // service control manager handle schm, // service handle schs : SC_Handle; // service status ss : TServiceStatus; // current service status dwStat : DWord; begin dwStat := -1; // connect to the service control manager schm := OpenSCManager( PChar(sMachine), Nil, SC_MANAGER_CONNECT); // if successful... if (schm > 0)then begin // open a handle to the specified service schs := OpenService( schm, PChar(sService), SERVICE_QUERY_STATUS); // if successful... if(schs > 0)then begin // retrieve the current status of the specified service if (QueryServiceStatus( schs, ss)) then begin dwStat := ss.dwCurrentState; end; // close service handle CloseServiceHandle(schs); end; // close service control // manager handle CloseServiceHandle(schm); end; Result := dwStat; end; |
Naahh.....
saat ini kita punya fungsi dasar -- "ServiceGetStatus()" -- untuk mendapat status dari service yang berjalan pada mesin tertentu, mari kita sederhanakan proses dengan menggunakan fungsi: "ServiceRunning()" and "ServiceStopped()"
function ServiceRunning( psMachine, psService : string ) : boolean; begin Result := SERVICE_RUNNING = ServiceGetStatus( psMachine, psService ); end; function ServiceStopped( psMachine, psService : string ) : boolean; begin Result := SERVICE_STOPPED = ServiceGetStatus( psMachine, psService ); end; |
Baik "ServiceRunning()" maupun "ServiceStopped()" membutuhkan nama mesin dan nama service. Nama Mesin dapat dikosongkan jika yang diuji adalah mesin lokal.
Contohnya:
if( ServiceRunning( '\ComputerName', 'alerter' ) ) then begin // service "alerter" di \ComputerName sedang berjalan // tulikan apa yg akan dilakukan disini |
Random Articles
- Mendeteksi Memory Leak (Memory Leak Detection)
- Membuat Fungsi Pembulatan Untuk Bilangan Desimal
- Elips dengan kemiringan tertentu
- Setting Alternatif Delphi IDE
- Tulis/Baca "string" di file .INI
- ADO QUERY
- EXE/PE File Protector
- Asosiasi Pengembang Software Indonesia, alternatif
- PascalTalk #3: RADically Fast and Easy Mobile Apps Development with Delphi
- Membuat DBNavigator dgn TAction
Last Articles
- Lazarus Release 2.0.12
- Project Group dalam Lazarus
- FastPlaz Database Explorer
- Release: FastPlaz Super Mom v0.12.22
- PascalClass #3: Web Development with Free Pascal
- Makna Pascal di Pascal Indonesia
- Kulgram : Instalasi Lazarus di Perangkat Berbasis ARM
- PascalClass #1: Analisa Database dan Machine Learning
- PascalTalk #6: (Podcast) Kuliah IT di luar negeri, susah gak sih?
- Mengenal OXYGENE – Pascal For .NET
Recent Topic
- PascalTalk #6: (Podcast) Kuliah IT di luar negeri, susah gak sih?
by LuriDarmawan in Tutorial & Community Project more 6 months ago - PascalTalk #5: UX: Research, Design and Engineer
by LuriDarmawan in Tutorial & Community Project more 6 months ago - PascalTalk #4: Obrolan Ringan Seputar IT
by LuriDarmawan in Tutorial & Community Project more 7 months ago - PascalTalk #2: Membuat Sendiri SMART HOME
by LuriDarmawan in Tutorial & Community Project more 7 months ago - PascalTalk #3: RADically Fast and Easy Mobile Apps Development with Delphi
by LuriDarmawan in Tutorial & Community Project more 7 months ago - PascalTalk #1: Pemanfaatan Artificial Intelligence di Masa Covid-19
by LuriDarmawan in Tutorial & Community Project more 7 months ago - Tempat Latihan Posting
by LuriDarmawan in OOT more 1 years ago - Archive
- Looping lagi...
by idhiel in Hal umum tentang Pascal Indonesia more 8 years ago - [ask] koneksi ke ODBC user Dsn saat runtime dengan ado
by halimanh in FireBird more 8 years ago - Validasi menggunakan data tanggal
by mas_kofa in Hal umum tentang Pascal Indonesia more 8 years ago