반응형
내가 만든 강종 프로그램...
약간 수정했네요...
C:\ 가 있어야 하고,, C:\가 없으면 실행불 =ㅅ=; C드라이브에 Config 파일을 생성합니다.
실행시키고 1단계 2단계 3단계 설정하시고 스타트하시면 됩니다.
재미로 만들었고 특별한 상황에 요긴하게 쓰면 ㅇㅋ
--- 발로짠 코드 =ㅅ=;
var reboot: Treboot; gTray: TNOTIFYICONDATA; implementation {$R *.dfm} function Treboot.MyExitWindows(RebootParam: Longword): Boolean; var TTokenHd: THandle; TTokenPvg: TTokenPrivileges; cbtpPrevious: DWORD; rTTokenPvg: TTokenPrivileges; pcbtpPreviousRequired: DWORD; tpResult: Boolean; const SE_SHUTDOWN_NAME = 'SeShutdownPrivilege'; begin if Win32Platform = VER_PLATFORM_WIN32_NT then begin tpResult := OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,TTokenHd); if tpResult then begin tpResult := LookupPrivilegeValue(nil,SE_SHUTDOWN_NAME,TTokenPvg.Privileges[0].Luid); TTokenPvg.PrivilegeCount := 1; TTokenPvg.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED; cbtpPrevious := SizeOf(rTTokenPvg); pcbtpPreviousRequired := 0; if tpResult then Windows.AdjustTokenPrivileges(TTokenHd,False,TTokenPvg,cbtpPrevious,rTTokenPvg,pcbtpPreviousRequired); end; end; Result := ExitWindowsEx(RebootParam, 0); end; procedure Treboot.startClick(Sender: TObject); var timeIni : TIniFile; begin timeIni := TIniFile.Create('C:\Time.ini'); with timeIni do begin if sDate.Caption = '무한 작업' then begin WriteString('TimeReboot', 'Mode', sJob.Caption); WriteString('TimeReboot', 'Date', sDate.Caption); WriteString('TimeReboot', 'Time', sTime.Caption); WriteString('TimeReboot', 'Start', sNum.Caption); end else if sDate.Caption <> '무한 작업' then begin WriteString('TimeReboot', 'Mode', '...'); WriteString('TimeReboot', 'Date', '...'); WriteString('TimeReboot', 'Time', '...'); WriteString('TimeReboot', 'Start', '...'); end; end; timeIni.Free; jongRyu1.Enabled := False; jongRyu2.Enabled := False; date_one.Enabled := False; date_mu.Enabled := False; start.Enabled := False; end; function Treboot.rebootT:Boolean; begin result := false; if (sTime.Caption = time_p.Text) and (sDate.Caption = '무한 작업') then begin result := True; end else if (sTime.Caption = time_p.Text) and (sDate.Caption = date_p.Text) then begin result := True; end else if (sDate.Caption <> date_p.Text) and (sTime.Caption <> time_p.Text) then begin result := false; end; end; procedure Treboot.FormCreate(Sender: TObject); var timeIni: TIniFile; begin sSkinManager1.Active := True; timeIni := TIniFile.Create('C:\Time.ini'); with timeIni do begin sJob.Caption := ReadString('TimeReboot', 'Mode', ''); sDate.Caption := ReadString('TimeReboot', 'Date', ''); sTime.Caption := ReadString('TimeReboot', 'Time', ''); sNum.Caption := ReadString('TimeReboot', 'Start', ''); time_s.Time := NOW; date_s.Date := NOW; timeIni.Free; end; dataEnble; if sDate.Caption = '무한 작업' then begin jongRyu1.Enabled := False; jongRyu2.Enabled := False; date_one.Enabled := False; date_mu.Enabled := False; start.Enabled := False; stop.Enabled := True; end; Timer1.Enabled := True; end; procedure Treboot.Timer1Timer(Sender: TObject); begin time_p.Text := FormatDateTime('HH:MM:SS',NOW); date_p.Text := FormatDateTime('YYYY-MM-DD',NOW); if not (rebootT) then exit; if sJob.Caption = '컴퓨터 리붓' then begin //showmessage('reboot'); MyExitWindows(EWX_REBOOT or EWX_FORCE); end else if sJob.Caption = '컴퓨터 종료' then begin //showmessage('Off'); MyExitWindows(EWX_POWEROFF or EWX_FORCE); end; end; procedure Treboot.stopClick(Sender: TObject); var timeIni : TIniFile; begin timeIni := TIniFile.Create('C:\Time.ini'); with timeIni do begin WriteString('TimeReboot', 'Mode', '...'); WriteString('TimeReboot', 'Date', '...'); WriteString('TimeReboot', 'Time', '...'); WriteString('TimeReboot', 'Start', '...'); timeIni.Free; end; jongRyu1.Enabled := True; jongRyu2.Enabled := True; date_one.Enabled := True; date_mu.Enabled := True; start.Enabled := True; time_s.Time := NOW; date_s.Date := NOW; sJob.Caption := '...'; sDate.Caption := '...'; sTime.Caption := '...'; sNum.Caption := '...'; dataEnble; end; procedure Treboot.WndProc(var Msg: TMessage); begin if Msg.WParam = SC_MINIMIZE then begin//최소화버튼 눌렀을때 트레이로 ShowWindow( Application.Handle, SW_MINIMIZE ); //테스크바.. gTray.Wnd := reboot.Handle; gTray.uId := 1; gTray.uFlags := NIF_ICON + NIF_TIP + NIF_MESSAGE; gTray.ucallbackMessage := WM_RBUTTONDOWN ; gTray.hIcon := reboot.Icon.Handle; //폼의아이콘 -> Tray 아이콘 gTray.szTip := '재부팅 프로그램' + #13#10 + '실행중입니다.'; //툴 팁~ ShellApi.Shell_NotifyIcon( NIM_ADD, @gTray ); ShowWindow( Application.Handle, SW_HIDE ); //테스크바에서 사라지게 end else begin case Msg.LParam of WM_LBUTTONDBLCLK://트레이의 아이콘 좌측더블클릭시 begin ShowWindow( Application.Handle, SW_SHOW ); // 태스크바에 보이기 ShowWindow( Application.Handle, SW_RESTORE ); // 폼 되돌리기 Shell_NotifyIcon( NIM_DELETE, @gTray ); // 트레이의 아이콘 삭제 end; end; end; inherited; end; procedure Treboot.jongRyu1Click(Sender: TObject); begin sJob.Caption := jongRyu1.Caption; dataEnble; end; procedure Treboot.jongRyu2Click(Sender: TObject); begin sJob.Caption := jongRyu2.Caption; dataEnble; end; procedure Treboot.date_oneClick(Sender: TObject); begin sDate.Caption := FormatDateTime('YYYY-MM-DD', date_s.Date); sTime.Caption := FormatDateTime('HH:MM:SS', time_s.DateTime); sNum.Caption := date_one.Caption; dataEnble; end; procedure Treboot.date_muClick(Sender: TObject); begin sDate.Caption := '무한 작업'; sTime.Caption := FormatDateTime('HH:MM:SS', time_s.DateTime); sNum.Caption := date_mu.Caption; dataEnble; end; procedure Treboot.dataEnble; begin if sTime.Caption <> '...' then begin start.Enabled := True; stop.Enabled := True; end else if sJob.Caption <> '...' then begin date_one.Enabled := True; date_mu.Enabled := True; end else if sNum.Caption = '...' then begin date_one.Enabled := False; date_mu.Enabled := False; start.Enabled := False; stop.Enabled := False; end; end; end.
반응형