X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e622dd68c2b1ae0616963ed3e761d6b3b4596b12..f7f78039d2e18114efdec0abe46dc4ed2d4529a8:/src/msw/utils.cpp diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index 66414baaa2..30e41428af 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -5,8 +5,8 @@ // Modified by: // Created: 04/01/98 // RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Copyright: (c) Julian Smart +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -48,7 +48,7 @@ #include "wx/timer.h" -#if !defined(__GNUWIN32__) && !defined(__WXWINE__) && !defined(__SALFORDC__) && !defined(__WXMICROWIN__) +#if !defined(__GNUWIN32__) && !defined(__SALFORDC__) && !defined(__WXMICROWIN__) #include #ifndef __MWERKS__ @@ -78,8 +78,10 @@ #include #endif // USE_NET_API -#if defined(__WIN32__) && !defined(__WXWINE__) && !defined(__WXMICROWIN__) - #include +#if defined(__WIN32__) && !defined(__WXMICROWIN__) + #ifndef __UNIX__ + #include + #endif #ifndef __GNUWIN32__ #include @@ -662,6 +664,8 @@ struct wxFindByPidParams // the PID we're looking from DWORD pid; + + DECLARE_NO_COPY_CLASS(wxFindByPidParams) }; // wxKill helper: EnumWindows() callback which is used to find the first (top @@ -872,7 +876,7 @@ bool wxShell(const wxString& command) return wxExecute(cmd, wxEXEC_SYNC) == 0; } -// Shutdown or reboot the PC +// Shutdown or reboot the PC bool wxShutdown(wxShutdownFlags wFlags) { #ifdef __WIN32__ @@ -880,31 +884,29 @@ bool wxShutdown(wxShutdownFlags wFlags) if ( wxGetOsVersion(NULL, NULL) == wxWINDOWS_NT ) // if is NT or 2K { - // Get a token for this process. - HANDLE hToken; + // Get a token for this process. + HANDLE hToken; bOK = ::OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken) != 0; -#ifndef __WXWINE__ if ( bOK ) { - TOKEN_PRIVILEGES tkp; + TOKEN_PRIVILEGES tkp; - // Get the LUID for the shutdown privilege. + // Get the LUID for the shutdown privilege. ::LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, - &tkp.Privileges[0].Luid); + &tkp.Privileges[0].Luid); - tkp.PrivilegeCount = 1; // one privilege to set - tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; + tkp.PrivilegeCount = 1; // one privilege to set + tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; - // Get the shutdown privilege for this process. + // Get the shutdown privilege for this process. ::AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, - (PTOKEN_PRIVILEGES)NULL, 0); + (PTOKEN_PRIVILEGES)NULL, 0); - // Cannot test the return value of AdjustTokenPrivileges. + // Cannot test the return value of AdjustTokenPrivileges. bOK = ::GetLastError() == ERROR_SUCCESS; } -#endif } if ( bOK ) @@ -925,7 +927,7 @@ bool wxShutdown(wxShutdownFlags wFlags) return FALSE; } - bOK = ::ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE | EWX_REBOOT, 0) != 0; + bOK = ::ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE | EWX_REBOOT, 0) != 0; } return bOK; @@ -1106,6 +1108,8 @@ void wxUsleep(unsigned long milliseconds) #else // !Win32 if (gs_inTimer) return; + if (miliseconds <= 0) + return; wxTheSleepTimer = new wxSleepTimer; gs_inTimer = TRUE; @@ -1124,6 +1128,8 @@ void wxSleep(int nSecs) { if (gs_inTimer) return; + if (nSecs <= 0) + return; wxTheSleepTimer = new wxSleepTimer; gs_inTimer = TRUE;