Click here to Skip to main content
15,921,793 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: resize bitmap resource Pin
Anonymous14-Apr-04 14:46
Anonymous14-Apr-04 14:46 
GeneralRe: resize bitmap resource Pin
Christian Graus14-Apr-04 14:51
protectorChristian Graus14-Apr-04 14:51 
GeneralRe: resize bitmap resource Pin
Anonymous14-Apr-04 15:40
Anonymous14-Apr-04 15:40 
GeneralRe: resize bitmap resource Pin
Christian Graus14-Apr-04 15:45
protectorChristian Graus14-Apr-04 15:45 
GeneralRe: resize bitmap resource Pin
PJ Arends14-Apr-04 20:34
professionalPJ Arends14-Apr-04 20:34 
GeneralRe: resize bitmap resource Pin
Christian Graus15-Apr-04 10:27
protectorChristian Graus15-Apr-04 10:27 
GeneralRe: resize bitmap resource Pin
PJ Arends15-Apr-04 11:32
professionalPJ Arends15-Apr-04 11:32 
GeneralShutting Down when not Logged Off Pin
reymano14-Apr-04 12:10
reymano14-Apr-04 12:10 
I wrote a small program to shutdown my computer at a scheduled time (using the task scheduler to run the program at the end of the day). The program works except when I'm logged off from the computer (i.e. the welcome or login screen is displayed). The program still runs and terminates will an exit code of 0, but the shutdown never happened. Here's a sample of the code:

void CPowerdownDlg::OnOK() <br />
{<br />
  if (!mode) // shutdown<br />
  {<br />
    HANDLE procHnd, tokHnd;<br />
<br />
    procHnd = GetCurrentProcess();<br />
<br />
    if (!OpenProcessToken(procHnd,TOKEN_ADJUST_PRIVILEGES,&tokHnd))<br />
      return;<br />
<br />
    TOKEN_PRIVILEGES tp;<br />
    LUID luid;<br />
<br />
    if (!LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &luid))<br />
      return; <br />
<br />
    tp.PrivilegeCount = 1;<br />
    tp.Privileges[0].Luid = luid;<br />
    tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;<br />
<br />
    AdjustTokenPrivileges(tokHnd, FALSE, &tp, 0, NULL, 0); <br />
<br />
//		ExitWindowsEx(EWX_POWEROFF | EWX_FORCEIFHUNG, 0);<br />
    InitiateSystemShutdownEx(NULL, NULL, 15, TRUE, FALSE, SHTDN_REASON_FLAG_PLANNED);<br />
<br />
  }<br />
  else if (mode == 1) // standby<br />
    SetSuspendState(FALSE,TRUE,FALSE);<br />
  else if (mode == 2) // hibernate<br />
    SetSuspendState(TRUE,TRUE,FALSE);<br />
<br />
  OnClose();<br />
}



This is an MFC app where the dialog displays a countdown to auto-shutdown or the user can force it manually (by clicking the OK button). Of course when no one is logged on, the program will shutdown the computer without user intervention. I've tried using ExitWindowsEx() but the results were the same. Strange though that hibernating (mode 2) works when I'm logged off. I'm using XP Pro.

I'm puzzled Confused | :confused:
reymano
GeneralDOS string parsing Pin
Ravi Bhavnani14-Apr-04 11:16
professionalRavi Bhavnani14-Apr-04 11:16 
GeneralRe: DOS string parsing Pin
Gary R. Wheeler14-Apr-04 13:07
Gary R. Wheeler14-Apr-04 13:07 
GeneralAbout ICOPYHOOK Interface... Pin
ZarrinPour14-Apr-04 10:04
ZarrinPour14-Apr-04 10:04 
GeneralRe: About ICOPYHOOK Interface... Pin
vcplusplus14-Apr-04 10:42
vcplusplus14-Apr-04 10:42 
GeneralWINVER related question Pin
Maarten Kools14-Apr-04 9:47
professionalMaarten Kools14-Apr-04 9:47 
GeneralRe: WINVER related question Pin
Joe Woodbury14-Apr-04 10:29
professionalJoe Woodbury14-Apr-04 10:29 
GeneralRe: WINVER related question Pin
Maarten Kools14-Apr-04 10:31
professionalMaarten Kools14-Apr-04 10:31 
GeneralRe: WINVER related question Pin
Joe Woodbury14-Apr-04 13:10
professionalJoe Woodbury14-Apr-04 13:10 
GeneralRe: WINVER related question Pin
Maarten Kools14-Apr-04 13:40
professionalMaarten Kools14-Apr-04 13:40 
Generalreinterpret_cast question Pin
ursus zeta14-Apr-04 9:32
ursus zeta14-Apr-04 9:32 
GeneralRe: reinterpret_cast question Pin
Maarten Kools14-Apr-04 9:40
professionalMaarten Kools14-Apr-04 9:40 
GeneralRe: reinterpret_cast question Pin
ursus zeta14-Apr-04 9:54
ursus zeta14-Apr-04 9:54 
GeneralRe: reinterpret_cast question Pin
Maarten Kools14-Apr-04 10:15
professionalMaarten Kools14-Apr-04 10:15 
GeneralRe: reinterpret_cast question Pin
Gary R. Wheeler14-Apr-04 13:38
Gary R. Wheeler14-Apr-04 13:38 
GeneralRe: reinterpret_cast question Pin
Paul Ranson14-Apr-04 11:08
Paul Ranson14-Apr-04 11:08 
GeneralThanks for info Pin
ursus zeta14-Apr-04 12:39
ursus zeta14-Apr-04 12:39 
QuestionHow do I display image data? Pin
Member 15847214-Apr-04 9:22
Member 15847214-Apr-04 9:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.