2022年操作系统系统调用数据结构

上传人:人*** 文档编号:567370832 上传时间:2024-07-20 格式:PDF 页数:35 大小:345.50KB
返回 下载 相关 举报
2022年操作系统系统调用数据结构_第1页
第1页 / 共35页
2022年操作系统系统调用数据结构_第2页
第2页 / 共35页
2022年操作系统系统调用数据结构_第3页
第3页 / 共35页
2022年操作系统系统调用数据结构_第4页
第4页 / 共35页
2022年操作系统系统调用数据结构_第5页
第5页 / 共35页
点击查看更多>>
资源描述

《2022年操作系统系统调用数据结构》由会员分享,可在线阅读,更多相关《2022年操作系统系统调用数据结构(35页珍藏版)》请在金锄头文库上搜索。

1、OSVERSIONINFOEX This is preliminary documentation and subject to change.The OSVERSIONINFOEX structure contains operating system version information. The information includes major and minor version numbers, a build number, a platform identifier, and information about the latest Service Pack installe

2、d on the system. This structure is used with the GetVersionEx function. OSVERSIONINFOEX is an extended version of the OSVERSIONINFO structure. typedef struct _OSVERSIONINFOEXA DWORD dwOSVersionInfoSize; DWORD dwMajorVersion; DWORD dwMinorVersion; DWORD dwBuildNumber; DWORD dwPlatformId; TCHAR szCSDV

3、ersion 128 ; WORD wServicePackMajor; WORD wServicePackMinor; WORD wReserved2; OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA; Members dwOSVersionInfoSizeSpecifies the size, in bytes, of this data structure. Set this member to sizeof ( OSVERSIONINFOEX) before calling the GetVersionExfuncti

4、on. dwMajorVersionIdentifies the major version number of the operating system. For example, for Windows NT version 5.0, the major version number is 5. dwMinorVersionIdentifies the minor version number of the operating system. For example, for Windows NT version 5.0, the minor version number is 0. dw

5、BuildNumberIdentifies the build number of the operating system. dwPlatformIdIdentifies the operating system platform. This member can be one of the following values. 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 35 页 - - - - - - - - - Value Platform VER_PLATFO

6、RM_WIN32s Win32s on Windows 3.1. VER_PLATFORM_WIN32_WINDOWS Win32 on Windows 95 or Windows 98. VER_PLATFORM_WIN32_NT Win32 on Windows NT. szCSDVersionContains a null-terminated string, such as Service Pack 3, that indicates the latest Service Pack installed on the system. If no Service Pack has been

7、 installed, the string is empty. wServicePackMajorIdentifies the major version number of the latest Service Pack installed on the system. If no Service Pack has been installed, the value is zero. wServicePackMinorIdentifies the minor version number of the latest Service Pack installed on the system.

8、 If no Service Pack has been installed, the value is zero. wReservedReserved for future use. QuickInfo Windows NT: Requires version 5.0 or later. Windows: Unsupported. Windows CE: Unsupported. Header: Declared in winbase.h. Unicode: Defined as Unicode and ANSI structures. GetProcessVersion The GetPr

9、ocessVersion function obtains the major and minor version numbers of the system on which a specified process expects to run. DWORD GetProcessVersion( DWORD ProcessId / identifier specifying the process of interest );Parameters 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - -

10、 - - 第 2 页,共 35 页 - - - - - - - - - ProcessIdProcess identifier that specifies the process of interest. A ProcessId value of zero specifies the calling process. Return Values If the function succeeds, the return value is the version of the system on which the process expects to run. The high word of

11、 the return value contains the major version number. The low word of the return value contains the minor version number. If the function fails, the return value is zero. To get extended error information, call GetLastError . The function fails if ProcessId is an invalid value. Remarks The GetProcess

12、Version function performs less quickly when ProcessIdis nonzero, specifying a process other than the calling process. The version number returned by this function is the version number stamped in the image header of the .EXE file the process is running. Linker programs set this value. QuickInfo Wind

13、ows NT: Requires version 3.51 or later. Windows: Requires Windows 95 or later. Windows CE: Unsupported. Header: Declared in winbase.h. Import Library: Use kernel32.lib. GetVersionEx The GetVersionEx function obtains extended information about the version of the operating system that is currently run

14、ning. BOOL GetVersionEx( LPOSVERSIONINFO lpVersionInformation / pointer to version / information structure );Parameters 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 35 页 - - - - - - - - - lpVersionInformationPointer to an OSVERSIONINFOdata structure that the

15、function fills with operating system version information. Before calling the GetVersionEx function, set the dwOSVersionInfoSizemember of the OSVERSIONINFOdata structure to sizeof (OSVERSIONINFO). Windows NT 5.0 and later: This member can be a pointer to an OSVERSIONINFOEX structure. Set the dwOSVers

16、ionInfoSize member to sizeof (OSVERSIONINFOEX) to identify the type of structure. Return Values If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError . The function fails if you specify an invalid

17、value for the dwOSVersionInfoSize member of the OSVERSIONINFO or OSVERSIONINFOEX structure. Remarks When using the GetVersionEx function to determine whether your application is running on a particular version of the operating system, check for version numbers that are greater than or equal to the d

18、esired version numbers. This ensures that the test succeeds for later versions of the operating system. For example, if your application requires Windows 98, use the following test: GetVersionEx (&osvi); bIsWindows98orLater = (osvi.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS) & ( (osvi.dwMajorVersion

19、4) | ( (osvi.dwMajorVersion = 4) & (osvi.dwMinorVersion 0) ) ); Identifying the current operating system is usually not the best way to determine whether a particular operating system feature is present. This is because the operating system may have had new features added in a redistributable DLL. R

20、ather than using GetVersionEx to determine the 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 35 页 - - - - - - - - - operating system platform or version number, test for the presence of the feature itself. To determine the best way to test for a feature, refer

21、 to the documentation for the feature of interest. The following list discusses some common techniques for feature detection: You can test for the presence of the functions associated with a feature. To test for the presence of a function in a system DLL, call the LoadLibrary function to load the DL

22、L. Then call the GetProcAddress function to determine whether the function of interest is present in the DLL. Use the pointer returned by GetProcAddress to call the function. Note that even if the function is present, it may be a stub that just returns an error code such as ERROR_CALL_NOT_IMPLEMENTE

23、D. You can determine the presence of some features by using the GetSystemMetrics function. For example, you can detect multiple display monitors by calling GetSystemMetrics (SM_CMONITORS). There are several versions of the redistributable DLLs that implement shell and common control features. For in

24、formation about determining which versions are present on the system your application is running on, see the topic Shell Versions . Windows CE: The value of the dwPlatformID member of the OSVERSIONINFOstructure will be VER_PLATFORM_WIN32_CE. QuickInfo Windows NT: Requires version 3.5 or later. Windo

25、ws: Requires Windows 95 or later. Windows CE: Requires version 1.0 or later. Header: Declared in winbase.h. 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 35 页 - - - - - - - - - Import Library: Use kernel32.lib. Unicode: Implemented as Unicode and ANSI versions

26、 on Windows NT. GetPriorityClass The GetPriorityClass function returns the priority class for the specified process. This value, together with the priority value of each thread of the process, determines each threads base priority level. DWORD GetPriorityClass( HANDLE hProcess / handle to the proces

27、s );Parameters hProcessHandle to the process. Windows NT: The handle must have PROCESS_QUERY_INFORMATION access. Return Values If the function succeeds, the return value is the priority class of the specified process. If the function fails, the return value is zero. To get extended error information

28、, call GetLastError . The processs priority class is one of the following values: Priority Meaning HIGH_PRIORITY_CLASS Indicates a process that performs time-critical tasks that must be executed immediately for it to run correctly. The threads of a high-priority class process preempt the threads of

29、normal or idle priority class processes. An example is the Task List, which must respond quickly when called by the user, regardless of the load on the operating system. Use extreme care when 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 6 页,共 35 页 - - - - - - - - -

30、 using the high-priority class, because a high-priority class CPU-bound application can use nearly all available cycles. IDLE_PRIORITY_CLASS Indicates a process whose threads run only when the system is idle and are preempted by the threads of any process running in a higher priority class. An examp

31、le is a screen saver. The idle priority class is inherited by child processes. NORMAL_PRIORITY_CLASS Indicates a normal process with no special scheduling needs. REALTIME_PRIORITY_CLASS Indicates a process that has the highest possible priority. The threads of a real-time priority class process pree

32、mpt the threads of all other processes, including operating system processes performing important tasks. For example, a real-time process that executes for more than a very brief interval can cause disk caches not to flush or cause the mouse to be unresponsive. Remarks Every thread has a base priori

33、ty level determined by the threads priority value and the priority class of its process. The operating system uses the base priority level of all executable threads to determine which thread gets the next slice of CPU time. Threads are scheduled in a round-robin fashion at each priority level, and o

34、nly when there are no executable threads at a higher level will scheduling of threads at a lower level take place. For a table that shows the base priority levels for each combination of priority class and thread priority value, see the SetPriorityClassfunction. QuickInfo Windows NT: Requires versio

35、n 3.1 or later. Windows: Requires Windows 95 or later. Windows CE: Unsupported. 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 7 页,共 35 页 - - - - - - - - - Header: Declared in winbase.h. Import Library: Use kernel32.lib. GetModuleFileName The GetModuleFileName functi

36、on retrieves the full path and filename for the executable file containing the specified module. Windows 95: The GetModuleFilename function will return long filenames when an applications version number is greater than or equal to 4.00 and the long filename is available. Otherwise, it returns only 8

37、.3 format filenames. DWORD GetModuleFileName( HMODULE hModule, / handle to module to find filename for LPTSTR lpFilename , / pointer to buffer to receive module path DWORD nSize / size of buffer, in characters );Parameters hModuleHandle to the module whose executable filename is being requested. If

38、this parameter is NULL, GetModuleFileName returns the path for the file used to create the calling process. lpFilenamePointer to a buffer that is filled in with the path and filename of the given module. nSizeSpecifies the length, in characters, of the lpFilename buffer. If the length of the path an

39、d filename exceeds this limit, the string is truncated. Return Values If the function succeeds, the return value is the length, in characters, of the string copied to the buffer. If the function fails, the return value is zero. To get extended error information, call GetLastError . Remarks 名师资料总结 -

40、- -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 8 页,共 35 页 - - - - - - - - - If a module is loaded in two processes, its module filename in one process may differ in case from its module filename in the other process. sprintf, swprintf Write formatted data to a string. intspri

41、ntf(char* buffer , constchar* format , argument . );intswprintf(wchar_t* buffer, constwchar_t* format , argument . );RoutineRequired HeaderCompatibilitysprintfANSI, Win 95, Win NTswprintf or ANSI, Win 95, Win NTFor additional compatibility information, see Compatibility in the Introduction. Librarie

42、sLIBC.LIBSingle thread static library, retail versionLIBCMT.LIBMultithread static library, retail versionMSVCRT.LIBImport library for MSVCRT.DLL, retail versionReturn Valuesprintf returns the number of bytes stored in buffer, not counting the terminating null character. swprintf returns the number o

43、f wide characters stored in buffer, not counting the terminating null wide character. ParametersbufferStorage location for output formatFormat-control string 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 9 页,共 35 页 - - - - - - - - - argumentOptional arguments For mo

44、re information, see Format Specifications. RemarksThe sprintf function formats and stores a series of characters and values in buffer . Each argument (if any) is converted and output according to the corresponding format specification in format. The format consists of ordinary characters and has the

45、 same form and function as the format argument for printf. A null character is appended after the last character written. If copying occurs between strings that overlap, the behavior is undefined. swprintf is a wide-character version of sprintf; the pointer arguments to swprintfare wide-character st

46、rings. Detection of encoding errors in swprintf may differ from that in sprintf. swprintf and fwprintf behave identically except that swprintf writes output to a string rather than to a destination of type FILE. Generic-Text Routine MappingsTCHAR.H Routine _UNICODE & _MBCS Not Defined_MBCS Defined_U

47、NICODE Defined_stprintfsprintfsprintfswprintfExample/* SPRINTF.C: This program uses sprintf to format various * data and place them in the string named buffer. */ #include void main( void ) char buffer200, s = computer, c = l; int i = 35, j; float fp = 1.7320534f; /* Format and print various data: *

48、/ j = sprintf( buffer, tString: %sn, s ); j += sprintf( buffer + j, tCharacter: %cn, c ); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 10 页,共 35 页 - - - - - - - - - j += sprintf( buffer + j, tInteger: %dn, i ); j += sprintf( buffer + j, tReal: %fn, fp ); printf( Ou

49、tput:n%sncharacter count = %dn, buffer, j ); OutputOutput: String: computer Character: l Integer: 35 Real: 1.732053 character count = 71 CreateProcess The CreateProcess function creates a new process and its primary thread. The new process executes the specified executable file. BOOL CreateProcess(

50、LPCTSTR lpApplicationName,/ pointer to name of executable module LPTSTR lpCommandLine, / pointer to command line string LPSECURITY_ATTRIBUTES lpProcessAttributes, / process security attributes LPSECURITY_ATTRIBUTES lpThreadAttributes, / thread security attributes BOOL bInheritHandles, / handle inher

51、itance flag DWORD dwCreationFlags , / creation flags LPVOID lpEnvironment, / pointer to new environment block LPCTSTR lpCurrentDirectory, / pointer to current directory name LPSTARTUPINFO lpStartupInfo, / pointer to STARTUPINFO LPPROCESS_INFORMATION lpProcessInformation / pointer to PROCESS_INFORMAT

52、ION );Parameters lpApplicationName名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 11 页,共 35 页 - - - - - - - - - Pointer to a null-terminated string that specifies the module to execute. The string can specify the full path and filename of the module to execute or it c

53、an specify a partial name. In the case of a partial name, the function uses the current drive and current directory to complete the specification. The lpApplicationName parameter can be NULL. In that case, the module name must be the first white space-delimited token in the lpCommandLinestring. If y

54、ou are using a long filename that contains a space, use quoted strings to indicate where the filename ends and the arguments begin, otherwise, the filename is ambiguous. For example, consider the string c:program filessub dirprogram name. This string can be interpreted in a number of ways. The syste

55、m tries the possibilities in the following order: c:program.exe filessub dirprogram name c:program filessub.exe dirprogram name c:program filessub dirprogram.exe name c:program filessub dirprogram name.exeThe specified module can be a Win32-based application. It can be some other type of module (for

56、 example, MS-DOS or OS/2) if the appropriate subsystem is available on the local computer. Windows NT: If the executable module is a 16-bit application, lpApplicationName should be NULL, and the string pointed to by lpCommandLine should specify the executable module. A 16-bit application is one that

57、 executes as a VDM or WOW process. lpCommandLinePointer to a null-terminated string that specifies the command line to execute. The system adds a null character to the command line, trimming the string if necessary, to indicate which file was actually used. The lpCommandLineparameter can be NULL. In

58、 that case, the function uses the string pointed to by lpApplicationNameas the command line. If both lpApplicationName and lpCommandLine are non-NULL, *lpApplicationName specifies the module to execute, and *lpCommandLinespecifies the command line. The new process can use GetCommandLine to retrieve

59、the entire command line. C runtime processes can use the argc and argv arguments. 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 12 页,共 35 页 - - - - - - - - - If lpApplicationNameis NULL, the first white space-delimited token of the command line specifies the module

60、name. If you are using a long filename that contains a space, use quoted strings to indicate where the filename ends and the arguments begin (see the explanation for the lpApplicationName parameter). If the filename does not contain an extension, .EXE is assumed. If the filename ends in a period (.)

61、 with no extension, or the filename contains a path, .EXE is not appended. If the filename does not contain a directory path, the system searches for the executable file in the following sequence: 1. The directory from which the application loaded. 2. The current directory for the parent process. 3.

62、 Windows 95 and Windows 98: The Windows system directory. Use the GetSystemDirectoryfunction to get the path of this directory. Windows NT: The 32-bit Windows system directory. Use the GetSystemDirectoryfunction to get the path of this directory. The name of this directory is SYSTEM32. 4. Windows NT

63、: The 16-bit Windows system directory. There is no Win32 function that obtains the path of this directory, but it is searched. The name of this directory is SYSTEM. 5. The Windows directory. Use the GetWindowsDirectoryfunction to get the path of this directory. 6. The directories that are listed in

64、the PATH environment variable. If the process to be created is an MS-DOS - based or 16-bit Windows-based application, lpCommandLineshould be a full command line in which the first element is the application name. Because this also works well for Win32-based applications, it is the most robust way to

65、 set lpCommandLine . lpProcessAttributes名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 13 页,共 35 页 - - - - - - - - - Pointer to a SECURITY_ATTRIBUTESstructure that determines whether the returned handle can be inherited by child processes. If lpProcessAttributes is N

66、ULL, the handle cannot be inherited. Windows NT: The lpSecurityDescriptor member of the structure specifies a security descriptor for the new process. If lpProcessAttributes is NULL, the process gets a default security descriptor. lpThreadAttributesPointer to a SECURITY_ATTRIBUTESstructure that dete

67、rmines whether the returned handle can be inherited by child processes. If lpThreadAttributes is NULL, the handle cannot be inherited. Windows NT: The lpSecurityDescriptor member of the structure specifies a security descriptor for the main thread. If lpThreadAttributes is NULL, the thread gets a de

68、fault security descriptor. bInheritHandlesIndicates whether the new process inherits handles from the calling process. If TRUE, each inheritable open handle in the calling process is inherited by the new process. Inherited handles have the same value and access privileges as the original handles. dw

69、CreationFlagsSpecifies additional flags that control the priority class and the creation of the process. The following creation flags can be specified in any combination, except as noted: Value Meaning CREATE_DEFAULT_ERROR_MODE The new process does not inherit the error mode of the calling process.

70、Instead, CreateProcess gives the new process the current default error mode. An application sets the current default error mode by calling SetErrorMode . This flag is particularly useful for multi-threaded shell applications that run with hard errors disabled. The default behavior for CreateProcess

71、is for the new process to inherit the error mode of the caller. Setting this flag changes that default behavior. CREATE_NEW_CONSOLE 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 14 页,共 35 页 - - - - - - - - - The new process has a new console, instead of inheriting t

72、he parents console. This flag cannot be used with the DETACHED_PROCESS flag. CREATE_NEW_PROCESS_GROUP The new process is the root process of a new process group. The process group includes all processes that are descendants of this root process. The process identifier of the new process group is the

73、 same as the process identifier, which is returned in the lpProcessInformationparameter. Process groups are used by the GenerateConsoleCtrlEvent function to enable sending a ctrl+c or ctrl+break signal to a group of console processes. CREATE_SEPARATE_WOW_VDM Windows NT: This flag is valid only when

74、starting a 16-bit Windows-based application. If set, the new process is run in a private Virtual DOS Machine (VDM). By default, all 16-bit Windows-based applications are run as threads in a single, shared VDM. The advantage of running separately is that a crash only kills the single VDM; any other p

75、rograms running in distinct VDMs continue to function normally. Also, 16-bit Windows-based applications that are run in separate VDMs have separate input queues. That means that if one application hangs momentarily, applications in separate VDMs continue to receive input. The disadvantage of running

76、 separately is that it takes significantly more memory to do so. You should use this flag only if the user requests that 16-bit applications should run in them own VDM. CREATE_SHARED_WOW_VDM Windows NT: The flag is valid only when starting a 16-bit Windows-based application. If the DefaultSeparateVD

77、M switch in the Windows section of WIN.INI is TRUE, this flag causes the CreateProcess function to override the switch and run the new process in the shared Virtual DOS Machine. CREATE_SUSPENDED The primary thread of the new process is created in a suspended state, and does not run until the ResumeT

78、hreadfunction is called. 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 15 页,共 35 页 - - - - - - - - - CREATE_UNICODE_ENVIRONMENT If set, the environment block pointed to by lpEnvironment uses Unicode characters. If clear, the environment block uses ANSI characters. D

79、EBUG_PROCESS If this flag is set, the calling process is treated as a debugger, and the new process is a process being debugged. The system notifies the debugger of all debug events that occur in the process being debugged. If you create a process with this flag set, only the calling thread (the thr

80、ead that called CreateProcess ) can call the WaitForDebugEvent function. Windows 95 and Windows 98: This flag is not valid if the new process is a 16-bit application. DEBUG_ONLY_THIS_PROCESS If not set and the calling process is being debugged, the new process becomes another process being debugged

81、by the calling processs debugger. If the calling process is not a process being debugged, no debugging-related actions occur. DETACHED_PROCESS For console processes, the new process does not have access to the console of the parent process. The new process can call the AllocConsole function at a lat

82、er time to create a new console. This flag cannot be used with the CREATE_NEW_CONSOLE flag. The dwCreationFlags parameter also controls the new processs priority class, which is used in determining the scheduling priorities of the processs threads. If none of the following priority class flags is sp

83、ecified, the priority class defaults to NORMAL_PRIORITY_CLASS unless the priority class of the creating process is IDLE_PRIORITY_CLASS. In this case the default priority class of the child process is IDLE_PRIORITY_CLASS. One of the following flags can be specified: Priority Meaning HIGH_PRIORITY_CLA

84、SS Indicates a process that performs time-critical tasks that must be 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 16 页,共 35 页 - - - - - - - - - executed immediately for it to run correctly. The threads of a high-priority class process preempt the threads of normal

85、-priority or idle-priority class processes. An example is the Task List, which must respond quickly when called by the user, regardless of the load on the system. Use extreme care when using the high-priority class, because a high-priority class CPU-bound application can use nearly all available cyc

86、les. IDLE_PRIORITY_CLASS Indicates a process whose threads run only when the system is idle and are preempted by the threads of any process running in a higher priority class. An example is a screen saver. The idle priority class is inherited by child processes. NORMAL_PRIORITY_CLASS Indicates a nor

87、mal process with no special scheduling needs. REALTIME_PRIORITY_CLASS Indicates a process that has the highest possible priority. The threads of a real-time priority class process preempt the threads of all other processes, including operating system processes performing important tasks. For example

88、, a real-time process that executes for more than a very brief interval can cause disk caches not to flush or cause the mouse to be unresponsive. lpEnvironmentPointer to an environment block for the new process. If this parameter is NULL, the new process uses the environment of the calling process.

89、名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 17 页,共 35 页 - - - - - - - - - An environment block consists of a null-terminated block of null-terminated strings. Each string is in the form: name=value Because the equal sign is used as a separator, it must not be used

90、 in the name of an environment variable. If an application provides an environment block, rather than passing NULL for this parameter, the current directory information of the system drives is not automatically propagated to the new process. For a discussion of this situation and how to handle it, s

91、ee the following Remarks section. An environment block can contain Unicode or ANSI characters. If the environment block pointed to by lpEnvironment contains Unicode characters, the dwCreationFlags fields CREATE_UNICODE_ENVIRONMENT flag will be set. If the block contains ANSI characters, that flag wi

92、ll be clear. Note that an ANSI environment block is terminated by two zero bytes: one for the last string, one more to terminate the block. A Unicode environment block is terminated by four zero bytes: two for the last string, two more to terminate the block. lpCurrentDirectoryPointer to a null-term

93、inated string that specifies the current drive and directory for the child process. The string must be a full path and filename that includes a drive letter. If this parameter is NULL, the new process is created with the same current drive and directory as the calling process. This option is provide

94、d primarily for shells that need to start an application and specify its initial drive and working directory. lpStartupInfoPointer to a STARTUPINFO structure that specifies how the main window for the new process should appear. lpProcessInformationPointer to a PROCESS_INFORMATION structure that rece

95、ives identification information about the new process. Return Values If the function succeeds, the return value is nonzero. 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 18 页,共 35 页 - - - - - - - - - If the function fails, the return value is zero. To get extended e

96、rror information, call GetLastError . Remarks The CreateProcess function is used to run a new program. The WinExec and LoadModule functions are still available, but they are implemented as calls to CreateProcess . In addition to creating a process, CreateProcess also creates a thread object. The thr

97、ead is created with an initial stack whose size is described in the image header of the specified programs executable file. The thread begins execution at the images entry point. The new process and the new thread handles are created with full access rights. For either handle, if a security descript

98、or is not provided, the handle can be used in any function that requires an object handle to that type. When a security descriptor is provided, an access check is performed on all subsequent uses of the handle before access is granted. If the access check denies access, the requesting process is not

99、 able to use the handle to gain access to the thread. The process is assigned a 32-bit process identifier. The identifier is valid until the process terminates. It can be used to identify the process, or specified in the OpenProcess function to open a handle to the process. The initial thread in the

100、 process is also assigned a 32-bit thread identifier. The identifier is valid until the thread terminates and can be used to uniquely identify the thread within the system. These identifiers are returned in the PROCESS_INFORMATION structure. When specifying an application name in the lpApplicationNa

101、me or lpCommandLine strings, it doesnt matter whether the application name includes the filename extension, with one exception: an MS-DOS based or Windows-based application whose filename extension is .COM must include the .COM extension. The calling thread can use the WaitForInputIdle function to w

102、ait until the new process has finished its initialization and is waiting for user input with no input pending. This can be useful for synchronization between parent and child processes, because CreateProcess returns without waiting for the new process to finish its initialization. For example, the c

103、reating process would use WaitForInputIdle before trying to find a window associated with the new process. 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 19 页,共 35 页 - - - - - - - - - The preferred way to shut down a process is by using the ExitProcessfunction, becau

104、se this function notifies all dynamic-link libraries (DLLs) attached to the process of the approaching termination. Other means of shutting down a process do not notify the attached DLLs. Note that when a thread calls ExitProcess , other threads of the process are terminated without an opportunity t

105、o execute any additional code (including the thread termination code of attached DLLs). ExitProcess , ExitThread , CreateThread , CreateRemoteThread, and a process that is starting (as the result of a call by CreateProcess ) are serialized between each other within a process. Only one of these event

106、s can happen in an address space at a time. This means the following restrictions hold: During process startup and DLL initialization routines, new threads can be created, but they do not begin execution until DLL initialization is done for the process. Only one thread in a process can be in a DLL i

107、nitialization or detach routine at a time. The ExitProcess function does not return until no threads are in their DLL initialization or detach routines. The created process remains in the system until all threads within the process have terminated and all handles to the process and any of its thread

108、s have been closed through calls to CloseHandle . The handles for both the process and the main thread must be closed through calls to CloseHandle . If these handles are not needed, it is best to close them immediately after the process is created. When the last thread in a process terminates, the f

109、ollowing events occur: All objects opened by the process are implicitly closed. The processs termination status (which is returned by GetExitCodeProcess ) changes from its initial value of STILL_ACTIVE to the termination status of the last thread to terminate. The thread object of the main thread is

110、 set to the signaled state, satisfying any threads that were waiting on the object. The process object is set to the signaled state, satisfying any threads that were waiting on the object. If the current directory on drive C is MSVCMFC, there is an environment variable called =C: whose value is C:MS

111、VCMFC. As noted in the previous description of lpEnvironment , such current directory information for a systems drives does not automatically propagate to a new process when the CreateProcess functions lpEnvironment parameter is non-NULL. An 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名

112、师精心整理 - - - - - - - 第 20 页,共 35 页 - - - - - - - - - application must manually pass the current directory information to the new process. To do so, the application must explicitly create the =X environment variable strings, get them into alphabetical order (because the system uses a sorted environmen

113、t), and then put them into the environment block specified by lpEnvironment . Typically, they will go at the front of the environment block, due to the previously mentioned environment block sorting. One way to obtain the current directory variable for a drive X is to call GetFullPathName( X:,. . )

114、. That avoids an application having to scan the environment block. If the full path returned is X:, there is no need to pass that value on as environment data, since the root directory is the default current directory for drive X of a new process. The handle returned by the CreateProcess function ha

115、s PROCESS_ALL_ACCESS access to the process object. The current directory specified by the lpcurrentDirectory parameter is the current directory for the child process. The current directory specified in item 2 under the lpCommandLine parameter is the current directory for the parent process. Windows

116、NT: When a process is created with CREATE_NEW_PROCESS_GROUP specified, an implicit call to SetConsoleCtrlHandler(NULL,TRUE) is made on behalf of the new process; this means that the new process has ctrl+c disabled. This lets good shells handle ctrl+c themselves, and selectively pass that signal on t

117、o sub-processes. ctrl+break is not disabled, and may be used to interrupt the process/process group. Windows CE: The name of the module to execute must be specified by the lpApplicationNameparameter. Windows CE does not support passing NULL for lpApplicationName . The execution module cannot be spec

118、ified in the command line string. Windows CE searches the directories indicated by the lpApplicationNameparameter in the following order: The root of the PC Card if it exists The windows (windows) directory The root ( ) directory of the device The following parameters are not supported and require t

119、he following settings: lpProcessAttributes must be NULL 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 21 页,共 35 页 - - - - - - - - - lpThreadAttributes must be NULL bInheritHandles must be FALSE lpEnvironment must be NULL lpCurrentDirectory must be NULL lpStartupInfo

120、 must be NULL For Windows CE version 1.0, the dwCreationFlags parameter only supports the following values: CREATE_SUSPENDED and zero. For Windows CE version 2.0, the dwCreationFlags parameter only supports the following values: CREATE_SUSPENDED, DEBUG_PROCESS, DEBUG_ONLY_THIS_PROCESS and zero. Prio

121、rity classes for processes are not supported. The loader has a limited search path. QuickInfo Windows NT: Requires version 3.1 or later. Windows: Requires Windows 95 or later. Windows CE: Requires version 1.0 or later. Header: Declared in winbase.h. Import Library: Use kernel32.lib. Unicode: Impleme

122、nted as Unicode and ANSI versions on Windows NT. CloseHandle The CloseHandle function closes an open object handle. BOOL CloseHandle( HANDLE hObject / handle to object to close );Parameters hObjectHandle to an open object. Return Values If the function succeeds, the return value is nonzero. 名师资料总结 -

123、 - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 22 页,共 35 页 - - - - - - - - - If the function fails, the return value is zero. To get extended error information, call GetLastError . Remarks The CloseHandle function closes handles to the following objects: Communications devic

124、e Console input Console screen buffer Event File File mapping Job Mailslot Mutex Named pipe Process Semaphore Socket Thread Token CloseHandle invalidates the specified object handle, decrements the objects handle count, and performs object retention checks. After the last handle to an object is clos

125、ed, the object is removed from the system. Closing a thread handle does not terminate the associated thread. To remove a thread object, you must terminate the thread, then close all handles to the thread. Use CloseHandle to close handles returned by calls to the CreateFilefunction. Use FindClose to

126、close handles returned by calls to the FindFirstFile function. Closing an invalid handle raises an exception. This includes closing a handle twice, not checking the return value and closing an invalid handle, and using CloseHandle on a handle returned by FindFirstFile. Windows CE: Windows CE does no

127、t support closing handles to the following objects: Console input or output File mapping Named pipe 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 23 页,共 35 页 - - - - - - - - - Semaphore Token QuickInfo Windows NT: Requires version 3.1 or later. Windows: Requires Win

128、dows 95 or later. Windows CE: Requires version 1.0 or later. Header: Declared in winbase.h. Import Library: Use kernel32.lib. CreateMutex The CreateMutex function creates a named or unnamed mutex object. HANDLE CreateMutex( LPSECURITY_ATTRIBUTES lpMutexAttributes,/ pointer to security attributes BOO

129、L bInitialOwner, / flag for initial ownership LPCTSTR lpName / pointer to mutex-object name );Parameters lpMutexAttributesPointer to a SECURITY_ATTRIBUTESstructure that determines whether the returned handle can be inherited by child processes. If lpMutexAttributes is NULL, the handle cannot be inhe

130、rited. Windows NT: The lpSecurityDescriptor member of the structure specifies a security descriptor for the new mutex. If lpMutexAttributes is NULL, the mutex gets a default security descriptor. bInitialOwnerSpecifies the initial owner of the mutex object. If this value is TRUE and the caller create

131、d the mutex, the calling thread obtains ownership of the mutex object. Otherwise, the calling thread does not obtain ownership of the mutex. To determine if the caller created the mutex, see the Return Values section. lpNamePointer to a null-terminated string specifying the name of the mutex object.

132、 The name is limited to MAX_PATH characters and can contain 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 24 页,共 35 页 - - - - - - - - - any character except the backslash path-separator character (). Name comparison is case sensitive. If lpNamematches the name of an

133、 existing named mutex object, this function requests MUTEX_ALL_ACCESS access to the existing object. In this case, the bInitialOwnerparameter is ignored because it has already been set by the creating process. If the lpMutexAttributesparameter is not NULL, it determines whether the handle can be inh

134、erited, but its security-descriptor member is ignored. If lpName is NULL, the mutex object is created without a name. If lpNamematches the name of an existing event, semaphore, waitable timer, job, or file-mapping object, the function fails and the GetLastError function returns ERROR_INVALID_HANDLE.

135、 This occurs because these objects share the same name space. Return Values If the function succeeds, the return value is a handle to the mutex object. If the named mutex object existed before the function call, the function returns a handle to the existing object and GetLastError returns ERROR_ALRE

136、ADY_EXISTS. Otherwise, the caller created the mutex. If the function fails, the return value is NULL. To get extended error information, call GetLastError . Remarks The handle returned by CreateMutex has MUTEX_ALL_ACCESS access to the new mutex object and can be used in any function that requires a

137、handle to a mutex object. Any thread of the calling process can specify the mutex-object handle in a call to one of the wait functions. The single-object wait functions return when the state of the specified object is signaled. The multiple-object wait functions can be instructed to return either wh

138、en any one or when all of the specified objects are signaled. When a wait function returns, the waiting thread is released to continue its execution. The state of a mutex object is signaled when it is not owned by any thread. The creating thread can use the bInitialOwner flag to request immediate ow

139、nership of the mutex. Otherwise, a thread must use one of the wait functions to request ownership. When the mutexs state is signaled, one 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 25 页,共 35 页 - - - - - - - - - waiting thread is granted ownership, the mutexs stat

140、e changes to nonsignaled, and the wait function returns. Only one thread can own a mutex at any given time. The owning thread uses the ReleaseMutex function to release its ownership. The thread that owns a mutex can specify the same mutex in repeated wait function calls without blocking its executio

141、n. Typically, you would not wait repeatedly for the same mutex, but this mechanism prevents a thread from deadlocking itself while waiting for a mutex that it already owns. However, to release its ownership, the thread must call ReleaseMutex once for each time that the mutex satisfied a wait. Two or

142、 more processes can call CreateMutex to create the same named mutex. The first process actually creates the mutex, and subsequent processes open a handle to the existing mutex. This enables multiple processes to get handles of the same mutex, while relieving the user of the responsibility of ensurin

143、g that the creating process is started first. When using this technique, you should set the bInitialOwnerflag to FALSE; otherwise, it can be difficult to be certain which process has initial ownership. Multiple processes can have handles of the same mutex object, enabling use of the object for inter

144、process synchronization. The following object-sharing mechanisms are available: A child process created by the CreateProcess function can inherit a handle to a mutex object if the lpMutexAttributes parameter of CreateMutex enabled inheritance. A process can specify the mutex-object handle in a call

145、to the DuplicateHandle function to create a duplicate handle that can be used by another process. A process can specify the name of a mutex object in a call to the OpenMutex or CreateMutex function. Use the CloseHandle function to close the handle. The system closes the handle automatically when the

146、 process terminates. The mutex object is destroyed when its last handle has been closed. Windows CE: The lpMutexAttributes parameter must be set to NULL. QuickInfo Windows NT: Requires version 3.1 or later. Windows: Requires Windows 95 or later. Windows CE: Requires version 1.0 or later. 名师资料总结 - -

147、-精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 26 页,共 35 页 - - - - - - - - - Header: Declared in winbase.h. Import Library: Use kernel32.lib. Unicode: Implemented as Unicode and ANSI versions on Windows NT. Sleep The Sleep function suspends the execution of the current thread f

148、or a specified interval. VOID Sleep( DWORD dwMilliseconds / sleep time in milliseconds );Parameters dwMillisecondsSpecifies the time, in milliseconds, for which to suspend execution. A value of zero causes the thread to relinquish the remainder of its time slice to any other thread of equal priority

149、 that is ready to run. If there are no other threads of equal priority ready to run, the function returns immediately, and the thread continues execution. A value of INFINITE causes an infinite delay. Return Values This function does not return a value. Remarks A thread can relinquish the remainder

150、of its time slice by calling this function with a sleep time of zero milliseconds. You have to be careful when using Sleep and code that directly or indirectly creates windows. If a thread creates any windows, it must process messages. Message broadcasts are sent to all windows in the system. If you

151、 have a thread that uses Sleep with infinite delay, the system will deadlock. Two examples of code that indirectly creates windows are DDE and COM CoInitialize. Therefore, if you have a thread that creates windows, use MsgWaitForMultipleObjects or MsgWaitForMultipleObjectsEx, rather than Sleep. Quic

152、kInfo 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 27 页,共 35 页 - - - - - - - - - Windows NT: Requires version 3.1 or later. Windows: Requires Windows 95 or later. Windows CE: Requires version 1.0 or later. Header: Declared in winbase.h. Import Library: Use kernel32

153、.lib. ReleaseMutex The ReleaseMutex function releases ownership of the specified mutex object. BOOL ReleaseMutex( HANDLE hMutex / handle to mutex object );Parameters hMutexHandle to the mutex object. The CreateMutex or OpenMutex function returns this handle. Return Values If the function succeeds, t

154、he return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError . Remarks The ReleaseMutex function fails if the calling thread does not own the mutex object. A thread gets ownership of a mutex by specifying a handle to the mutex in o

155、ne of the wait functions. The thread that creates a mutex object can also get immediate ownership without using one of the wait functions. When the owning thread no longer needs to own the mutex object, it calls the ReleaseMutex function. While a thread has ownership of a mutex, it can specify the s

156、ame mutex in additional wait-function calls without blocking its execution. This prevents a thread from deadlocking itself while waiting for a mutex that 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 28 页,共 35 页 - - - - - - - - - it already owns. However, to release

157、 its ownership, the thread must call ReleaseMutex once for each time that the mutex satisfied a wait. QuickInfo Windows NT: Requires version 3.1 or later. Windows: Requires Windows 95 or later. Windows CE: Requires version 1.0 or later. Header: Declared in winbase.h. OpenMutex The OpenMutexfunction

158、returns a handle to an existing named mutex object. 函数返回一个已有的有名字的互斥对象的句柄。HANDLE OpenMutex( DWORD dwDesiredAccess , / 访问标志 access flag BOOL bInheritHandle, / 继承标志 inherit flag LPCTSTR lpName / 指向互斥对象名字的指针pointer to mutex-object name );Parameters dwDesiredAccessSpecifies the requested access to the mu

159、tex object. For systems that support object security, the function fails if the security descriptor of the specified object does not permit the requested access for the calling process. This parameter can be any combination of the following values: Access Description MUTEX_ALL_ACCESS Specifies all p

160、ossible access flags for the mutex object. SYNCHRONIZE Windows NT: Enables use of the mutex handle in any of the wait functions to acquire ownership of the mutex, or in the ReleaseMutex function to release ownership. 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 29

161、页,共 35 页 - - - - - - - - - bInheritHandleSpecifies whether the returned handle is inheritable. If TRUE, a process created by the CreateProcess function can inherit the handle; otherwise, the handle cannot be inherited. lpNamePointer to a null-terminated string that names the mutex to be opened. Name

162、 comparisons are case sensitive. Return Values If the function succeeds, the return value is a handle to the mutex object. If the function fails, the return value is NULL. To get extended error information, call GetLastError . Remarks The OpenMutexfunction enables multiple processes to open handles

163、of the same mutex object. The function succeeds only if some process has already created the mutex by using the CreateMutex function. The calling process can use the returned handle in any function that requires a handle to a mutex object, such as the wait functions, subject to the limitations of th

164、e access specified in the dwDesiredAccess parameter. The handle can be duplicated by using the DuplicateHandle function. Use the CloseHandle function to close the handle. The system closes the handle automatically when the process terminates. The mutex object is destroyed when its last handle has be

165、en closed. QuickInfo Windows NT: Requires version 3.1 or later. Windows: Requires Windows 95 or later. Windows CE: Unsupported. Header: Declared in winbase.h. Import Library: Use kernel32.lib. Unicode: Implemented as Unicode and ANSI versions on Windows NT. WaitForSingleObject The WaitForSingleObjec

166、t function returns when one of the following occurs: 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 30 页,共 35 页 - - - - - - - - - 指定的对象为有信号状态The specified object is in the signaled state. 等待超时 The time-out interval elapses. DWORD WaitForSingleObject( HANDLE hHandle ,

167、 / handle to object to wait for DWORD dwMilliseconds / time-out interval in milliseconds );Parameters hHandleHandle to the object. For a list of the object types whose handles can be specified, see the following Remarks section. Windows NT: The handle must have SYNCHRONIZE access. For more informati

168、on, see Standard Access Rights. dwMillisecondsSpecifies the time-out interval, in milliseconds. The function returns if the interval elapses, even if the objects state is nonsignaled. If dwMilliseconds is zero, the function tests the objects state and returns immediately. If dwMilliseconds is INFINI

169、TE, the functions time-out interval never elapses. Return Values If the function succeeds, the return value indicates the event that caused the function to return. This value can be one of the following. Value Meaning WAIT_ABANDONED The specified object is a mutex object that was not released by the

170、 thread that owned the mutex object before the owning thread terminated. Ownership of the mutex object is granted to the calling thread, and the mutex is set to nonsignaled. WAIT_OBJECT_0 The state of the specified object is signaled. WAIT_TIMEOUT The time-out interval elapsed, and the objects state

171、 is nonsignaled. 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 31 页,共 35 页 - - - - - - - - - If the function fails, the return value is WAIT_FAILED. To get extended error information, call GetLastError . Remarks The WaitForSingleObject function checks the current st

172、ate of the specified object. If the objects state is nonsignaled, the calling thread enters an efficient wait state. The thread consumes very little processor time while waiting for the object state to become signaled or the time-out interval to elapse. Before returning, a wait function modifies the

173、 state of some types of synchronization objects. Modification occurs only for the object whose signaled state caused the function to return. For example, the count of a semaphore object is decreased by one. The WaitForSingleObject function can wait for the following objects: Change notification Cons

174、ole input Event Job Mutex Process Semaphore Thread Waitable timer For more information, see Synchronization Objects. Use caution when calling the wait functions and code that directly or indirectly creates windows. If a thread creates any windows, it must process messages. Message broadcasts are sen

175、t to all windows in the system. A thread that uses a wait function with no time-out interval may cause the system to become deadlocked. Two examples of code that indirectly creates windows are DDE and COM CoInitialize. Therefore, if you have a thread that creates windows, use MsgWaitForMultipleObjec

176、ts or MsgWaitForMultipleObjectsEx, rather than WaitForSingleObject. Windows CE: Windows CE does not support waiting for semaphores, change notification objects, console input, and timers. Waiting on an invalid handle causes WaitForSingleObject to return WAIT_FAILED. 名师资料总结 - - -精品资料欢迎下载 - - - - - -

177、- - - - - - - - - - - - 名师精心整理 - - - - - - - 第 32 页,共 35 页 - - - - - - - - - QuickInfo Windows NT: Requires version 3.1 or later. Windows: Requires Windows 95 or later. Windows CE: Requires version 1.0 or later. Header: Declared in winbase.h. Import Library: Use kernel32.lib. WaitForSingleObject The

178、 WaitForSingleObject function returns when one of the following occurs: The specified object is in the signaled state. The time-out interval elapses. DWORD WaitForSingleObject( HANDLE hHandle, / handle to object to wait for DWORD dwMilliseconds / time-out interval in milliseconds );Parameters hHandl

179、eHandle to the object. For a list of the object types whose handles can be specified, see the following Remarks section. Windows NT: The handle must have SYNCHRONIZE access. For more information, see Standard Access Rights. dwMillisecondsSpecifies the time-out interval, in milliseconds. The function

180、 returns if the interval elapses, even if the objects state is nonsignaled. If dwMilliseconds is zero, the function tests the objects state and returns immediately. If dwMilliseconds is INFINITE, the functions time-out interval never elapses. Return Values If the function succeeds, the return value

181、indicates the event that caused the function to return. This value can be one of the following. 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 33 页,共 35 页 - - - - - - - - - Value Meaning WAIT_ABANDONED The specified object is a mutex object that was not released by t

182、he thread that owned the mutex object before the owning thread terminated. Ownership of the mutex object is granted to the calling thread, and the mutex is set to nonsignaled. WAIT_OBJECT_0 The state of the specified object is signaled. WAIT_TIMEOUT The time-out interval elapsed, and the objects sta

183、te is nonsignaled. If the function fails, the return value is WAIT_FAILED. To get extended error information, call GetLastError . Remarks The WaitForSingleObject function checks the current state of the specified object. If the objects state is nonsignaled, the calling thread enters an efficient wai

184、t state. The thread consumes very little processor time while waiting for the object state to become signaled or the time-out interval to elapse. Before returning, a wait function modifies the state of some types of synchronization objects. Modification occurs only for the object whose signaled stat

185、e caused the function to return. For example, the count of a semaphore object is decreased by one. The WaitForSingleObject function can wait for the following objects: Change notification Console input Event Job Mutex Process Semaphore Thread Waitable timer For more information, see Synchronization

186、Objects. Use caution when calling the wait functions and code that directly or indirectly creates windows. If a thread creates any windows, it must 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 34 页,共 35 页 - - - - - - - - - process messages. Message broadcasts are s

187、ent to all windows in the system. A thread that uses a wait function with no time-out interval may cause the system to become deadlocked. Two examples of code that indirectly creates windows are DDE and COM CoInitialize. Therefore, if you have a thread that creates windows, use MsgWaitForMultipleObj

188、ects or MsgWaitForMultipleObjectsEx, rather than WaitForSingleObject. Windows CE: Windows CE does not support waiting for semaphores, change notification objects, console input, and timers. Waiting on an invalid handle causes WaitForSingleObject to return WAIT_FAILED. QuickInfo Windows NT: Requires version 3.1 or later. Windows: Requires Windows 95 or later. Windows CE: Requires version 1.0 or later. Header: Declared in winbase.h. Import Library: Use kernel32.lib. 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 35 页,共 35 页 - - - - - - - - -

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 建筑/环境 > 施工组织

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号