📄 win32.cxx
字号:
/* * win32.cxx * * Miscellaneous implementation of classes for Win32 * * Portable Windows Library * * Copyright (c) 1993-1998 Equivalence Pty. Ltd. * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. * * The Original Code is Portable Windows Library. * * The Initial Developer of the Original Code is Equivalence Pty. Ltd. * * Portions are Copyright (C) 1993 Free Software Foundation, Inc. * All Rights Reserved. * * Contributor(s): ______________________________________. * * $Log: win32.cxx,v $ * Revision 1.148 2005/07/13 12:48:32 csoutheren * Backported fix from isvo branch * * Revision 1.147 2005/06/07 07:41:42 csoutheren * Applied patch 1176459 for PocketPC. Thanks to Matthias Weber * * Revision 1.146.2.1 2005/04/25 13:12:39 shorne * Fixed OSConfigDir for win32/NT/XP * * Revision 1.146 2005/02/02 23:21:16 csoutheren * Fixed problem with race condition in HousekeepingThread * Thanks to an idea from Auri Vizgaitis * * Revision 1.145 2005/01/25 11:28:25 csoutheren * Changed parms to CreateEvent to be more clear * * Revision 1.144 2005/01/16 23:00:36 csoutheren * Fixed problem when calling WaitForTermination from within the same thread * * Revision 1.143 2005/01/11 06:57:15 csoutheren * Fixed namespace collisions with plugin starup factories * * Revision 1.142 2005/01/04 07:44:04 csoutheren * More changes to implement the new configuration methodology, and also to * attack the global static problem * * Revision 1.141 2004/11/17 12:50:44 csoutheren * Win32 DCOM support, thanks to Simon Horne * * Revision 1.140 2004/10/31 22:22:06 csoutheren * Added pragma to include ole32.lib for static builds * * Revision 1.139 2004/10/23 10:50:28 ykiryanov * Added ifdef _WIN32_WCE for PocketPC 2003 SDK port * * Revision 1.138 2004/09/17 04:05:12 csoutheren * Changed Windows PDirectory semantics to be the same as Unix * * Revision 1.137 2004/06/09 13:35:11 csoutheren * Disabled "wait for key" at end of program unless in debug mode or PMEMORY_CHECK * is enabled * * Revision 1.136 2004/05/21 00:28:40 csoutheren * Moved PProcessStartup creation to PProcess::Initialise * Added PreShutdown function and called it from ~PProcess to handle PProcessStartup removal * * Revision 1.135 2004/04/09 06:52:18 rjongbloed * Removed #pargma linker command for /delayload of DLL as documentations sais that * you cannot do this. * * Revision 1.134 2004/04/03 06:54:30 rjongbloed * Many and various changes to support new Visual C++ 2003 * * Revision 1.133 2004/02/23 23:52:20 csoutheren * Added pragmas to avoid every Windows application needing to include libs explicitly * * Revision 1.132 2003/11/10 20:52:26 dereksmithies * add fix from Diego Tartara to recognize win XP and 2003 Server. Many thanks. * * Revision 1.131 2003/11/08 01:43:05 rjongbloed * Fixed race condition that could start two housekeeping threads, thanks Ted Szoczei * * Revision 1.130 2003/11/05 05:56:08 csoutheren * Added #pragma to include required libs * * Revision 1.129 2003/10/27 03:29:11 csoutheren * Added support for QoS * Thanks to Henry Harrison of AliceStreet * * Revision 1.128 2003/09/17 05:45:10 csoutheren * Removed recursive includes * * Revision 1.127 2003/02/26 01:12:52 robertj * Fixed race condition where thread can terminatebefore an IsSuspeded() call * occurs and cause an assert, thanks Sebastian Meyer * * Revision 1.126 2002/12/11 22:25:04 robertj * Added ability to set user identity temporarily and permanently. * Added get and set users group functions. * * Revision 1.125 2002/11/20 02:38:38 robertj * Fixed file path parsing for common unix/dos path error. * * Revision 1.124 2002/11/20 00:58:58 robertj * Made file path parsing slightly smarter for common unix/dos path error. * * Revision 1.123 2002/11/19 10:28:50 robertj * Changed PFilePath so can be empty string, indicating illegal path. * * Revision 1.122 2002/09/23 07:17:24 robertj * Changes to allow winsock2 to be included. * * Revision 1.121 2002/06/04 00:25:31 robertj * Fixed incorrectly initialised trace indent, thanks Artis Kugevics * * Revision 1.120 2002/04/24 01:11:05 robertj * Fixed problem with PTRACE_BLOCK indent level being correct across threads. * * Revision 1.119 2002/01/26 15:05:35 yurik * Removed extra ifdefs * * Revision 1.118 2002/01/23 04:45:50 craigs * Added copy Constructors for PSemaphore, PMutex and PSyncPoint * * Revision 1.117 2001/12/08 00:22:37 robertj * Prevented assert if doing SetUserName() with empty string. * * Revision 1.116 2001/11/23 06:59:00 robertj * Added PProcess::SetUserName() function for effective user changes. * * Revision 1.115 2001/10/26 04:20:25 craigs * Changed housekeeping thread to be Normal priority to avoide starvation * of PTimer dependent threads * * Revision 1.114 2001/10/23 05:42:48 robertj * Fixed bug in retry loop waiting for termination, applies only to heavily * laoded Win98 class machines. * * Revision 1.113 2001/10/07 16:05:59 yurik * Removed MFC dependency * * Revision 1.112 2001/09/11 03:27:46 robertj * Improved error processing on high level protocol failures, usually * caused by unexpected shut down of a socket. * * Revision 1.111 2001/09/10 02:51:23 robertj * Major change to fix problem with error codes being corrupted in a * PChannel when have simultaneous reads and writes in threads. * * Revision 1.110 2001/08/07 03:20:39 robertj * Fixed close of DLL so flagged as closed, thanks Stefan Ditscheid. * * Revision 1.109 2001/07/09 01:35:48 robertj * Added name to housekeeper thread. * * Revision 1.108 2001/06/01 04:03:05 yurik * Removed dependency on obsolete function * * Revision 1.107 2001/05/29 00:49:18 robertj * Added ability to put in a printf %x in thread name to get thread object * address into user settable thread name. * * Revision 1.106 2001/05/10 15:21:30 yurik * Fixed bug in PSemaphore::Signal(), courtesy of Dave Cassel, dcassel@cyberfone.com. * Also Refined thread priorities for WinCE. * * Revision 1.105 2001/05/04 05:42:23 yurik * GetUserName for Pocket PC (Windows CE 3.0) implemented * * Revision 1.104 2001/04/26 06:07:34 yurik * UI improvements * * Revision 1.103 2001/04/15 03:38:42 yurik * Removed shutdown flag. Use IsTerminated() instead * * Revision 1.102 2001/04/14 04:54:03 yurik * Added process shutdown flag * * Revision 1.101 2001/03/24 05:52:42 robertj * Added Windows 98 and ME to GetOSName() * Added build number to GetOSVersion() * * Revision 1.100 2001/03/03 00:55:02 yurik * Proper fix for filetime routines used in guid calc done for WinCE * * Revision 1.99 2001/02/13 06:55:21 robertj * Fixed problem with operator= in PDirectory class, part of larger change previously made. * * Revision 1.98 2001/01/30 06:37:52 yurik * Modification submitted by Dave Cassel, dcassel@cyberfone.com * DC: ARM, x86em were content without this change, but SH4 insisted * * Revision 1.97 2001/01/29 01:19:32 robertj * Fixed Win32 compile broken by WinCE changes. * * Revision 1.96 2001/01/28 01:50:46 yurik * WinCE port-related. System version check and new semaphore code * * Revision 1.95 2001/01/24 06:44:35 yurik * Windows CE port-related changes * * Revision 1.94 2000/11/02 01:31:11 robertj * Fixed problem with PSemaphore::WillBlock actually locking semaphore. * * Revision 1.93 2000/10/20 05:31:53 robertj * Added function to change auto delete flag on a thread. * * Revision 1.92 2000/08/25 08:07:48 robertj * Added Windows 2000 to operating system reporting. * * Revision 1.91 2000/04/05 02:50:18 robertj * Added microseconds to PTime class. * * Revision 1.90 2000/03/29 04:31:59 robertj * Removed assertion on terminating terminated thread, this is really OK. * * Revision 1.89 2000/03/04 08:07:27 robertj * Fixed problem with window not appearing when assert on GUI based win32 apps. * * Revision 1.88 2000/02/29 12:26:15 robertj * Added named threads to tracing, thanks to Dave Harvey * * Revision 1.87 2000/01/06 14:09:42 robertj * Fixed problems with starting up timers,losing up to 10 seconds * * Revision 1.86 1999/11/18 02:22:53 robertj * Fixed bug in GetErrorText() occasionally returning incorrect empty string, thanks Ulrich Findeisen * * Revision 1.85 1999/07/06 13:37:07 robertj * Fixed bug in PThread::IsSuspended(), returned exactly the opposite state! * * Revision 1.84 1999/07/06 04:46:01 robertj * Fixed being able to case an unsigned to a PTimeInterval. * Improved resolution of PTimer::Tick() to be millisecond accurate. * * Revision 1.83 1999/03/09 10:30:19 robertj * Fixed ability to have PMEMORY_CHECK on/off on both debug/release versions. * * Revision 1.82 1999/03/09 08:19:15 robertj * Adjustment found during documentation frenzy. * * Revision 1.81 1999/02/12 01:01:57 craigs * Fixed problem with linking static versions of libraries * * Revision 1.80 1999/01/30 14:28:25 robertj * Added GetOSConfigDir() function. * * Revision 1.79 1999/01/16 02:00:29 robertj * Added hardware description funtion. * * Revision 1.78 1998/12/04 10:10:47 robertj * Added virtual for determining if process is a service. Fixes linkage problem. * * Revision 1.77 1998/11/30 07:31:18 robertj * New directory structure * Fission of file into pipe.cxx, winserial.cxx and wincfg.cxx * * Revision 1.76 1998/11/26 10:35:08 robertj * Improved support of FAT32 and large NTFS volumes in GetFreeSpace(). * * Revision 1.75 1998/11/20 03:17:19 robertj * Added thread WaitForTermination() function. * * Revision 1.74 1998/11/19 05:19:53 robertj * Bullet proofed WaitForMultipleObjects under 95. * * Revision 1.73 1998/11/02 10:07:20 robertj * Added capability of pip output to go to stdout/stderr. * * Revision 1.72 1998/10/31 12:50:47 robertj * Removed ability to start threads immediately, race condition with vtable (Main() function). * Rearranged PPipChannel functions to help with multi-platform-ness. * * Revision 1.71 1998/10/29 11:29:20 robertj * Added ability to set environment in sub-process. * * Revision 1.70 1998/10/28 00:59:12 robertj * Fixed problem when reading standard error from pipe channel, no terminating null on string. * * Revision 1.69 1998/10/26 09:11:31 robertj * Added ability to separate out stdout from stderr on pipe channels. * * Revision 1.68 1998/10/15 02:20:26 robertj * Added message for connection aborted error. * * Revision 1.67 1998/10/13 14:13:36 robertj * Removed uneeded heap allocation. * * Revision 1.66 1998/09/24 03:30:59 robertj * Added open software license. * * Revision 1.65 1998/09/18 13:56:20 robertj * Added support of REG_BINARY registry types in PConfig class. * * Revision 1.64 1998/08/20 06:05:28 robertj * Allowed Win32 class to be used in other compilation modules * * Revision 1.63 1998/04/01 01:52:42 robertj * Fixed problem with NoAutoDelete threads. * * Revision 1.62 1998/03/29 06:16:56 robertj * Rearranged initialisation sequence so PProcess descendent constructors can do "things". * * Revision 1.61 1998/03/27 10:52:39 robertj * Fixed crash bug in win95 OSR2 GetVolumeSpace(). * Fixed error 87 problem with threads. * Fixed GetVolumeSpace() when UNC used. * * Revision 1.60 1998/03/20 03:19:49 robertj * Added special classes for specific sepahores, PMutex and PSyncPoint. * * Revision 1.59 1998/03/17 10:17:09 robertj * Fixed problem with viewing registry entries where the section ends with a \. * * Revision 1.58 1998/03/09 11:17:38 robertj * FAT32 compatibility * * Revision 1.57 1998/03/05 12:48:37 robertj * Fixed bug in get free space on volume. * Added cluster size. * MemCheck fixes. * * Revision 1.56 1998/02/16 00:10:45 robertj * Added function to open a URL in a browser. * Added functions to validate characters in a filename. * * Revision 1.55 1998/01/26 00:57:09 robertj * Fixed uninitialised source in PConfig when getting environment. * * Revision 1.54 1997/08/28 12:50:21 robertj * Fixed race condition in cleaning up threads on application termination. * * Revision 1.53 1997/08/21 13:27:41 robertj * Attempt to fix very slight possibility of endless loop in housekeeping thread. * * Revision 1.52 1997/08/21 12:44:56 robertj * Removed extension from DLL "short" name. * * Revision 1.51 1997/08/07 11:57:42 robertj * Added ability to get registry data from other applications and anywhere in system registry. * * Revision 1.50 1997/08/04 10:38:43 robertj * Fixed infamous error 87 assert failure in housekeeping thread. * * Revision 1.49 1997/07/14 11:47:22 robertj * Added "const" to numerous variables. * * Revision 1.48 1997/06/16 13:15:53 robertj * Added function to get a dyna-link libraries name. * * Revision 1.47 1997/06/08 04:42:41 robertj * Added DLL file extension string function. * * Revision 1.46 1997/03/28 04:36:30 robertj * Added assert for error in thread cleanup wait. * * Revision 1.45 1997/02/05 11:50:58 robertj * Changed current process function to return reference and validate objects descendancy. * * Revision 1.44 1997/01/12 04:24:16 robertj * Added function to get disk size and free space. * * Revision 1.43 1997/01/01 11:17:06 robertj * Added implementation for PPipeChannel::GetReturnCode and PPipeChannel::IsRunning * * Revision 1.44 1996/12/29 13:05:03 robertj * Added wait and abort for pipe channel commands. * Added setting of error codes on status error. * * Revision 1.43 1996/12/29 02:53:13 craigs * Added implementation for PPipeChannel::GetReturnCode and * PPipeChannel::IsRunning * * Revision 1.42 1996/12/17 13:13:05 robertj * Fixed win95 support for registry security code, * * Revision 1.41 1996/12/17 11:00:28 robertj * Fixed register entry security access control lists. * * Revision 1.40 1996/11/16 10:52:48 robertj * Fixed bug in PPipeChannel test for open channel, win95 support. * Put time back to C function as run time library bug fixed now. * * Revision 1.39 1996/11/04 03:36:31 robertj * Added extra error message for UDP packet truncated. * * Revision 1.38 1996/10/26 01:42:51 robertj * Added more translations for winsock error codes to standard error codes. * * Revision 1.37 1996/10/14 03:11:25 robertj * Changed registry key so when reading only opens in ReadOnly mode. * * Revision 1.36 1996/10/08 13:03:47 robertj * Added new error messages. * * Revision 1.35 1996/08/08 10:03:43 robertj * Fixed static error text returned when no osError value. * * Revision 1.34 1996/07/27 04:05:31 robertj * Created static version of ConvertOSError(). * Created static version of GetErrorText(). * Changed thread creation to use C library function instead of direct WIN32. * Fixed bug in auto-deleting the housekeeping thread. * * Revision 1.33 1996/07/20 05:34:05 robertj * Fixed order of registry section tree traversal so can delete whole trees. * * Revision 1.32 1996/06/28 13:24:33 robertj * Fixed enumeration of sections to recurse into registry tree. * * Revision 1.31 1996/06/17 11:38:58 robertj * Fixed memory leak on termination of threads. * * Revision 1.30 1996/06/13 13:32:13 robertj * Rewrite of auto-delete threads, fixes Windows95 total crash. * * Revision 1.29 1996/06/10 09:54:35 robertj * Fixed Win95 compatibility for semaphores. * * Revision 1.28 1996/05/30 11:48:51 robertj * Fixed error on socket timeout to return "Timed Out". * * Revision 1.27 1996/05/23 10:05:36 robertj * Fixed bug in PConfig::GetBoolean(). * Changed PTimeInterval millisecond access function so can get int64. * Moved service process code into separate module. * * Revision 1.26 1996/04/29 12:23:22 robertj * Fixed ability to access GDI stuff from subthreads. * Added function to return process ID. * * Revision 1.25 1996/04/17 12:09:30 robertj * Added service dependencies. * Started win95 support. * * Revision 1.24 1996/04/09 03:33:58 robertj * Fixed bug in incorrect report of timeout on socket read. * * Revision 1.23 1996/04/01 13:33:19 robertj * Fixed bug in install of service, incorrectly required installation before install. * * Revision 1.22 1996/03/31 09:10:33 robertj * Added use of "CurrentVersion" key in registry. * Added version display to service process. * Added another socket error text message. * * Revision 1.21 1996/03/12 11:31:39 robertj * Moved PProcess destructor to platform dependent code. * Fixed bug in deleting Event Viewer registry entry for service process. * * Revision 1.20 1996/03/10 13:16:49 robertj * Implemented system version functions. * * Revision 1.19 1996/03/04 13:07:33 robertj * Allowed for auto deletion of threads on termination. * * Revision 1.18 1996/02/25 11:15:29 robertj * Added platform dependent Construct function to PProcess. * * Revision 1.17 1996/02/25 03:12:48 robertj * Added consts to all GetXxxx functions in PConfig. * Fixed bug in PTime::GetTimeZone(), incorrect sign! * Fixed problem with PConfig get functions and their WIN32 types should be * able to interchange strings and numbers. * * Revision 1.16 1996/02/19 13:53:21 robertj * Fixed error reporting for winsock classes. * * Revision 1.15 1996/02/15 14:54:06 robertj * Compensated for C library bug in time(). * * Revision 1.14 1996/02/08 12:30:41 robertj * Time zone changes. * Added OS identification strings to PProcess. * * Revision 1.13 1996/01/28 02:56:56 robertj * Fixed bug in PFilePath functions for if path ends in a directory separator. * Made sure all directory separators are correct character in normalised path. * * Revision 1.12 1996/01/23 13:25:21 robertj * Added time zones. * Fixed bug if daylight savings indication. * * Revision 1.11 1996/01/02 12:58:33 robertj * Fixed copy of directories. * Changed process construction mechanism. * Made service process "common". * * Revision 1.10 1995/12/10 12:05:48 robertj * Changes to main() startup mechanism to support Mac. * Moved error code for specific WIN32 and MS-DOS versions. * Added WIN32 registry support for PConfig objects. * Added asserts in WIN32 semaphores. * * Revision 1.9 1995/11/21 11:53:24 robertj * Added timeout on semaphore wait. * * Revision 1.8 1995/10/14 15:13:04 robertj * Fixed bug in WIN32 service command line parameters.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -