diff options
author | George Hazan <george.hazan@gmail.com> | 2013-09-21 17:30:22 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-09-21 17:30:22 +0000 |
commit | 96325150479b8c93a5e48ac2591f3c7da5f0f9d4 (patch) | |
tree | 3df28331b050b503cecbf93dace3d6279b5affb1 /plugins/AutoShutdown | |
parent | 01d131efd5d40016f07d51c0a0e9451204aa6dc8 (diff) |
BroadcastSystemMessage is available in Win2k, no need to load it dynamically
git-svn-id: http://svn.miranda-ng.org/main/trunk@6164 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/AutoShutdown')
-rw-r--r-- | plugins/AutoShutdown/src/shutdownsvc.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/plugins/AutoShutdown/src/shutdownsvc.cpp b/plugins/AutoShutdown/src/shutdownsvc.cpp index a2d9f97078..d22ed2e2f3 100644 --- a/plugins/AutoShutdown/src/shutdownsvc.cpp +++ b/plugins/AutoShutdown/src/shutdownsvc.cpp @@ -48,7 +48,7 @@ static BOOL WinNT_SetPrivilege(TCHAR *pszPrivName,BOOL bEnable) TOKEN_PRIVILEGES tkp;
/* get a token for this process */
if(OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&hToken)) {
- tkp.PrivilegeCount=1; /* one privilege is to set */
+ tkp.PrivilegeCount=1; /* one privilege is to set */
/* get the LUID for the shutdown privilege */
if(LookupPrivilegeValue(NULL,pszPrivName,&tkp.Privileges[0].Luid)) {
tkp.Privileges[0].Attributes=bEnable?SE_PRIVILEGE_ENABLED:0;
@@ -62,10 +62,7 @@ static BOOL WinNT_SetPrivilege(TCHAR *pszPrivName,BOOL bEnable) static void BroadcastEndSession(DWORD dwRecipients,LPARAM lParam)
{
- LONG (WINAPI *pfnBroadcastSystemMessage)(DWORD,DWORD*,UINT,WPARAM,LPARAM);
- *(PROC*)&pfnBroadcastSystemMessage=GetProcAddress(GetModuleHandleA("USER32"),"BroadcastSystemMessageW");
- if(pfnBroadcastSystemMessage)
- pfnBroadcastSystemMessage(BSF_FORCEIFHUNG,&dwRecipients,WM_ENDSESSION,TRUE,lParam);
+ BroadcastSystemMessage(BSF_FORCEIFHUNG,&dwRecipients,WM_ENDSESSION,TRUE,lParam);
}
static BOOL WinNT_IsWorkStationLocked(void)
@@ -79,7 +76,7 @@ static BOOL WinNT_IsWorkStationLocked(void) bLocked=(!GetUserObjectInformation(hDesk,UOI_NAME,szName,SIZEOF(szName),&cbName) || lstrcmpi(szName,_T("default"))!=0);
CloseDesktop(hDesk);
return bLocked;
-}
+}
/************************* Workers ************************************/
static BOOL IsShutdownTypeEnabled(BYTE shutdownType)
@@ -133,7 +130,7 @@ static BOOL IsShutdownTypeEnabled(BYTE shutdownType) else if(IsWinVerNT()) /* for WinNT4 */
bReturn=SearchPath(NULL,_T("LOGIN.SCR"),NULL,0,NULL,NULL)!=0;
}
- break;
+ break;
case SDSDT_CLOSERASCONNECTIONS:
/* check if RAS installed/available */
bReturn=SearchPath(NULL,_T("RASAPI32"),_T(".DLL"),0,NULL,NULL)!=0;
@@ -143,7 +140,7 @@ static BOOL IsShutdownTypeEnabled(BYTE shutdownType) bReturn=TRUE; /* always possible */
break;
case SDSDT_REBOOT:
- case SDSDT_SHUTDOWN:
+ case SDSDT_SHUTDOWN:
/* test privileges */
if(IsWinVerNT()) {
bReturn=WinNT_SetPrivilege(SE_SHUTDOWN_NAME,TRUE);
@@ -309,7 +306,7 @@ static DWORD ShutdownNow(BYTE shutdownType) *(PROC*)&pfnInitiateSystemShutdown=GetProcAddress(GetModuleHandleA("ADVAPI32"),"InitiateSystemShutdownW");
if(pfnInitiateSystemShutdownEx!=NULL || pfnInitiateSystemShutdown!=NULL) {
WinNT_SetPrivilege(SE_SHUTDOWN_NAME,TRUE);
-
+
/* does not send out WM_ENDSESSION messages, so we do it manually to
* give the applications the chance to save their data */
WinNT_SetPrivilege(SE_TCB_NAME,TRUE); /* for BSM_ALLDESKTOPS */
@@ -343,7 +340,7 @@ static DWORD ShutdownNow(BYTE shutdownType) /* EWX_FORCE does not send out WM_ENDSESSION messages, so we do it
* manually to give the applications the chance to save their data */
BroadcastEndSession(BSM_APPLICATIONS,(shutdownType==SDSDT_LOGOFF)?ENDSESSION_LOGOFF:0);
-
+
/* Windows Me/98/95 (msdn): Because of the design of the shell,
* calling ExitWindowsEx with EWX_FORCE fails to completely log off
* the user (the system terminates the applications and displays the
@@ -376,7 +373,7 @@ static INT_PTR CALLBACK ShutdownDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR hwndShutdownDlg=hwndDlg;
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG)lParam);
TranslateDialogDefault(hwndDlg);
-
+
if(lParam==SDSDT_SHUTDOWN || lParam==SDSDT_REBOOT || lParam==SDSDT_LOGOFF)
ShowWindow(GetDlgItem(hwndDlg,IDC_TEXT_UNSAVEDWARNING),SW_SHOW);
SendDlgItemMessage(hwndDlg,IDC_ICON_HEADER,STM_SETIMAGE,IMAGE_ICON,(LPARAM)Skin_GetIcon("AutoShutdown_Header"));
@@ -398,7 +395,7 @@ static INT_PTR CALLBACK ShutdownDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR SkinPlaySound("AutoShutdown_Countdown");
if(!SetTimer(hwndDlg,1,1000,NULL)) PostMessage(hwndDlg,M_START_SHUTDOWN,0,0);
Utils_RestoreWindowPositionNoSize(hwndDlg,NULL,"AutoShutdown","ConfirmDlg_");
-
+
/* disallow foreground window changes (WinMe/2000+) */
SetForegroundWindow(hwndDlg);
*(PROC*)&pfnLockSetForegroundWindow=GetProcAddress(GetModuleHandleA("USER32"),"LockSetForegroundWindow");
|