::: µ¨ÆÄÀÌ Tip&Trick :::

µ¨ÆÄÀÌ Tip&Trick ¼º°Ý¿¡ ¸ÂÁö ¾Ê´Â ±¤°í,ºñ¹æ,Áú¹®ÀÇ ±ÛÀº Áï½Ã »èÁ¦Çϸç
³»¿ëÀ» º¹»çÇÏ¿© »ç¿ëÇÒ °æ¿ì ¹Ýµå½Ã À̰÷(http://www.howto.pe.kr)À» Ãâó·Î ¸í½ÃÇÏ¿© ÁÖ¼¼¿ä


Category

  ±è¿µ´ë(2004-07-22 19:50:55, Hit : 5004, Vote : 1275
 http://www.howto.pe.kr
 À©µµ¿ìÁî ¼­ºñ½º »óÅ ±¸Çϱâ

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, WinSvc, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
{$R *.dfm}

//-------------------------------------
// get service status
//
// return status code if successful
// -1 if not
//
// return codes:
//   SERVICE_STOPPED
//   SERVICE_RUNNING
//   SERVICE_PAUSED
//
// following return codes
// are used to indicate that
// the service is in the
// middle of getting to one
// of the above states:
//   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 := DWORD(-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),
      // we want to
      // query service status
      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;

//-------------------------------------
// return TRUE if the specified
// service is running, defined by
// the status code SERVICE_RUNNING.
// return FALSE if the service
// is in any other state, including
// any pending states
//
function ServiceRunning(
  sMachine,
  sService : string ) : boolean;
begin
  Result := SERVICE_RUNNING =
    ServiceGetStatus(
      sMachine, sService );
end;

//-------------------------------------
// return TRUE if the specified
// service was stopped, defined by
// the status code SERVICE_STOPPED.
//
function ServiceStopped(
  sMachine,
  sService : string ) : boolean;
begin
  Result := SERVICE_STOPPED =
    ServiceGetStatus(
      sMachine, sService );
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  // ¼­ºñ½º ½ÃÀÛµÊ(¿©±â¼­´Â DHCP Ŭ¶óÀÌ¾ðÆ®·Î Å×½ºÆ® ÇßÀ½)
  if( ServiceRunning(
    '',
    'Dhcp' ) )then
  begin
    ShowMessage('DHCP Client service on the local computer is running');
  end;

  // ¼­ºñ½º ÁßÁöµÊ
  if( ServiceStopped(
    '',
    'Dhcp' ) )then
  begin
    ShowMessage('DHCP Client on the local computer is in the stopped state');
  end;

{ // ´Ù¸¥ ÄÄÇ»ÅÍÀÇ ¼­ºñ½º »óÅ ±¸Çϱâ
  if( ServiceRunning(
    '\ComputerName',
    'Dhcp' ) )then
  begin
    ShowMessage("DHCP Client on \ComputerName is running take appropriate action here');
  end;
}  
end;

end.





211   [À©µµ¿ìÁî API] ÄÞÆ÷³ÍÆ®ÀÇ Hint ¿¡ ±×¸²(Bitmap) ³Ö±â  ±è¿µ´ë 2003/04/11 5189 1358
210   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] Űº¸µåÀÇ Shift+Tab ÀÌ ´­¸°°Íó·³ ó¸®ÇÏ±â  ±è¿µ´ë 2003/04/14 4732 1312
209   [À©µµ¿ìÁî API] ÆûÀÌ Minimized µÇ¾úÀ»¶§ ±ô¹ÚÀÌ°Ô Çϱâ 2  ±è¿µ´ë 2003/04/14 5970 1320
208   [COM/OLE] ±×¸®µå ÀÚ·á ¿¢¼¿·Î Á»´õ ºü¸£°Ô º¸³»±â  °ø¼ºÈ¯ 2003/04/16 5526 972
207   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] C¿¡¼­ ÇѱÛÀÚ¸£±â  °ø¼ºÈ¯ 2003/04/16 4843 966
206   [COM/OLE] ±âÁ¸ Excel ¹®¼­ ºÒ·¯¿Í¼­ ÆíÁýÈÄ ÀúÀåÇÏ±â  ±è¿µ´ë 2003/04/18 5437 1289
205   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] thread-safe Queue ±¸Çö  ±è¿µ´ë 2003/08/18 6123 1352
204   [¾Ë°í¸®Áò] ¼ýÀÚ¸¦ KB, MB, GB ´ÜÀ§·Î ȯ»êÇÏ±â  ±è¿µ´ë 2003/11/13 5064 1159
203   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] StrToFloatDef  ±è¿µ´ë 2003/11/13 4970 1258
202   [¾Ë°í¸®Áò] ±¸ºÐÀÚ(delimiter)¸¦ »ç¿ëÇÑ ¹®ÀÚ¿­ ÆÄ½Ì(parsing)  ±è¿µ´ë 2003/11/13 5166 1145
201   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] thread-safe Queue¸¦ ÀÌ¿ëÇÑ TLogThread  ±è¿µ´ë 2003/11/18 4795 1138
200   [³×Æ®¿÷/ÀÎÅͳÝ] IOCP(I/O Completion Port) class  ±è¿µ´ë 2003/11/18 11034 877
199   [³×Æ®¿÷/ÀÎÅͳÝ] Winsock WriteFile and Overlapped IO  ±è¿µ´ë 2003/11/18 5430 1230
198   [½Ã½ºÅÛ] À©µµ¿ìÁî ¼­ºñ½º ¸ñ·Ï ±¸ÇÏ±â  ±è¿µ´ë 2004/07/22 4556 1223
  [½Ã½ºÅÛ] À©µµ¿ìÁî ¼­ºñ½º »óÅ ±¸ÇÏ±â  ±è¿µ´ë 2004/07/22 5004 1275
196   [½Ã½ºÅÛ] À©µµ¿ìÁî ¼­ºñ½º ½ÃÀÛ/ÁßÁö ÇÏ±â  ±è¿µ´ë 2004/07/22 6095 1549
195   [½Ã½ºÅÛ] À©µµ¿ìÁî ½Ã½ºÅÛÀÇ ½ºÅ©·Ñ¹Ù µÎ²² ¹Ù²Ù±â  ±è¿µ´ë 2004/07/24 5618 1371
194   [½Ã½ºÅÛ] ¸¶¿ì½º ¾Æ·¡ÀÇ À©µµ¿ì ÇÚµé ±¸ÇÏ±â  ±è¿µ´ë 2004/07/24 8899 1606
193   [½Ã½ºÅÛ] ³» ÇÁ·Î±×·¥ÀÇ ½ÇÇà ¿ì¼±¼øÀÇ ¹Ù²Ù±â  ±è¿µ´ë 2004/07/24 5132 1399
192   [À©µµ¿ìÁî API] ³» ÇÁ·Î±×·¥ÀÇ È­¸éÀ» °¡¸®´Â ÇÁ·Î±×·¥ ¸®½ºÆ®  ±è¿µ´ë 2004/07/24 4567 1208
191   [À©µµ¿ìÁî API] Taskbar ÀÇ Æ¯Á¤ À§Ä¡¿¡ popup ¸Þ´º ¶ç¿ì±â  ±è¿µ´ë 2004/07/24 4606 1206
190   [À©µµ¿ìÁî API] Taskbar ÀÇ À§Ä¡ ÃßÀûÇÏ±â  ±è¿µ´ë 2004/07/24 3990 1072
189   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] À©µµ¿ìÁî"½ÃÀÛ" ¹öưÀ§¿¡ ±Û¾¾ ¾²±â  ±è¿µ´ë 2004/07/24 4195 1152
188   [½Ã½ºÅÛ] Á¦¾îÆÇÀÇ ¸ðµç applet Á¤º¸ ±¸ÇÏ±â  ±è¿µ´ë 2004/07/24 4423 1141
187   [À©µµ¿ìÁî API] ¹Ù·Î Á÷Àü¿¡ active µÇ¾ú´ø À©µµ¿ì¿Í ÄÜÆ®·Ñ ±¸ÇÏ±â  ±è¿µ´ë 2004/07/24 4637 1168
186   [À©µµ¿ìÁî API] Áö¿øÇϴ Űº¸µå ÀÔ·Â ¾ð¾î ±¸ÇÏ°í º¯°æÇÏ±â  ±è¿µ´ë 2004/07/24 4746 1269
185   [À©µµ¿ìÁî API] ÇöÀç Űº¸µå ÀÔ·Â ¾ð¾î ±¸ÇÏ±â  ±è¿µ´ë 2004/07/24 4985 1353
184   [COM/OLE] À©µµ¿ìÁî "ÀÛ¾÷ Ç¥½ÃÁÙ ¹× ½ÃÀÛ ¸Þ´º µî·Ï Á¤º¸" È­¸é  ±è¿µ´ë 2004/07/25 6077 1634
183   [COM/OLE] À©µµ¿ìÁî "ÀÎÅÍ³Ý µî·Ï Á¤º¸" È­¸é  ±è¿µ´ë 2004/07/25 4259 1325
182   [COM/OLE] À©µµ¿ìÁî "³¯Â¥/½Ã°£ µî·Ï Á¤º¸" È­¸é  ±è¿µ´ë 2004/07/25 6405 1653
181   [COM/OLE] À©µµ¿ìÁî "°Ë»ö: ÆÄÀÏ ¶Ç´Â Æú´õ" È­¸é  ±è¿µ´ë 2004/07/25 4983 1397
180   [COM/OLE] À©µµ¿ìÁî "½Ã½ºÅÛ Á¾·á" È­¸é  ±è¿µ´ë 2004/07/25 4606 1312
179   [COM/OLE] À©µµ¿ìÁî "¸ðµç âÀ» ÃÖ¼ÒÈ­"  ±è¿µ´ë 2004/07/25 6238 1708
178   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] TList ¸¦ ÀÌ¿ëÇÑ stack ±¸Á¶ ±¸Çö  ±è¿µ´ë 2004/07/25 4355 1133
177   [À©µµ¿ìÁî API] Æû¿¡ ¾Ö´Ï¸ÞÀÌ¼Ç È¿°ú ÁÖ±â  ±è¿µ´ë 2004/07/25 4642 1235
176   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] ¸ð¼­¸®°¡ µÕ±Ù(rounded ends) TMemo ¸¸µé±â  ±è¿µ´ë 2004/07/25 4546 1189
175   [½Ã½ºÅÛ] ·ÎÄà °¡»ó µå¶óÀ̹ö(substitution device) ¸¸µé°í Á¦°ÅÇÏ±â  ±è¿µ´ë 2004/07/25 5864 1326
174   [³×Æ®¿÷/ÀÎÅͳÝ] ³×Æ®¿öÅ© µå¶óÀÌºê ¿¬°á È­¸é ¶ç¿ì±â  ±è¿µ´ë 2004/07/26 5960 1601
173   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] TProgressbar ÀÇ »ö»ó ¹Ù²Ù±â  ±è¿µ´ë 2004/07/26 4627 1237
172   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] TTrewView, TListView ¸¦ À̹ÌÁö·Î ÀúÀåÇÏ±â  ±è¿µ´ë 2004/07/26 4340 965

[ÀÌÀü 10°³] [1]..[11][12][13][14][15][16][17][18][19] 20 ..[25] [´ÙÀ½ 10°³]
 

Copyright 1999-2022 Zeroboard / skin by zero