操作系统系统调用数据结构.docx
《操作系统系统调用数据结构.docx》由会员分享,可在线阅读,更多相关《操作系统系统调用数据结构.docx(30页珍藏版)》请在冰豆网上搜索。
操作系统系统调用数据结构
OSVERSIONINFOEX
[Thisispreliminarydocumentationandsubjecttochange.]
TheOSVERSIONINFOEXstructurecontainsoperatingsystemversioninformation.Theinformationincludesmajorandminorversionnumbers,abuildnumber,aplatformidentifier,andinformationaboutthelatestServicePackinstalledonthesystem.ThisstructureisusedwiththeGetVersionExfunction.OSVERSIONINFOEXisanextendedversionoftheOSVERSIONINFOstructure.
typedefstruct_OSVERSIONINFOEXA{
DWORDdwOSVersionInfoSize;
DWORDdwMajorVersion;
DWORDdwMinorVersion;
DWORDdwBuildNumber;
DWORDdwPlatformId;
TCHARszCSDVersion[128];
WORDwServicePackMajor;
WORDwServicePackMinor;
WORDwReserved[2];
}OSVERSIONINFOEXA,*POSVERSIONINFOEXA,*LPOSVERSIONINFOEXA;
Members
dwOSVersionInfoSize
Specifiesthesize,inbytes,ofthisdatastructure.Setthismembertosizeof(OSVERSIONINFOEX)beforecallingtheGetVersionExfunction.
dwMajorVersion
Identifiesthemajorversionnumberoftheoperatingsystem.Forexample,forWindowsNTversion5.0,themajorversionnumberis5.
dwMinorVersion
Identifiestheminorversionnumberoftheoperatingsystem.Forexample,forWindowsNTversion5.0,theminorversionnumberis0.
dwBuildNumber
Identifiesthebuildnumberoftheoperatingsystem.
dwPlatformId
Identifiestheoperatingsystemplatform.Thismembercanbeoneofthefollowingvalues.
Value
Platform
VER_PLATFORM_WIN32s
Win32sonWindows3.1.
VER_PLATFORM_WIN32_WINDOWS
Win32onWindows95orWindows98.
VER_PLATFORM_WIN32_NT
Win32onWindowsNT.
szCSDVersion
Containsanull-terminatedstring,suchas"ServicePack3",thatindicatesthelatestServicePackinstalledonthesystem.IfnoServicePackhasbeeninstalled,thestringisempty.
wServicePackMajor
IdentifiesthemajorversionnumberofthelatestServicePackinstalledonthesystem.IfnoServicePackhasbeeninstalled,thevalueiszero.
wServicePackMinor
IdentifiestheminorversionnumberofthelatestServicePackinstalledonthesystem.IfnoServicePackhasbeeninstalled,thevalueiszero.
wReserved
Reservedforfutureuse.
QuickInfo
WindowsNT:
Requiresversion5.0orlater.
Windows:
Unsupported.
WindowsCE:
Unsupported.
Header:
Declaredinwinbase.h.
Unicode:
DefinedasUnicodeandANSIstructures.
GetProcessVersion
TheGetProcessVersionfunctionobtainsthemajorandminorversionnumbersofthesystemonwhichaspecifiedprocessexpectstorun.
DWORDGetProcessVersion(
DWORDProcessId//identifierspecifyingtheprocessofinterest
);
Parameters
ProcessId
Processidentifierthatspecifiestheprocessofinterest.AProcessIdvalueofzerospecifiesthecallingprocess.
ReturnValues
Ifthefunctionsucceeds,thereturnvalueistheversionofthesystemonwhichtheprocessexpectstorun.Thehighwordofthereturnvaluecontainsthemajorversionnumber.Thelowwordofthereturnvaluecontainstheminorversionnumber.
Ifthefunctionfails,thereturnvalueiszero.Togetextendederrorinformation,callGetLastError.ThefunctionfailsifProcessIdisaninvalidvalue.
Remarks
TheGetProcessVersionfunctionperformslessquicklywhenProcessIdisnonzero,specifyingaprocessotherthanthecallingprocess.
Theversionnumberreturnedbythisfunctionistheversionnumberstampedintheimageheaderofthe.EXEfiletheprocessisrunning.Linkerprogramssetthisvalue.
QuickInfo
WindowsNT:
Requiresversion3.51orlater.
Windows:
RequiresWindows95orlater.
WindowsCE:
Unsupported.
Header:
Declaredinwinbase.h.
ImportLibrary:
Usekernel32.lib.
GetVersionEx
TheGetVersionExfunctionobtainsextendedinformationabouttheversionoftheoperatingsystemthatiscurrentlyrunning.
BOOLGetVersionEx(
LPOSVERSIONINFOlpVersionInformation//pointertoversion
//informationstructure
);
Parameters
lpVersionInformation
PointertoanOSVERSIONINFOdatastructurethatthefunctionfillswithoperatingsystemversioninformation.
BeforecallingtheGetVersionExfunction,setthedwOSVersionInfoSizememberoftheOSVERSIONINFOdatastructuretosizeof(OSVERSIONINFO).
WindowsNT5.0andlater:
ThismembercanbeapointertoanOSVERSIONINFOEXstructure.SetthedwOSVersionInfoSizemembertosizeof(OSVERSIONINFOEX)toidentifythetypeofstructure.
ReturnValues
Ifthefunctionsucceeds,thereturnvalueisnonzero.
Ifthefunctionfails,thereturnvalueiszero.Togetextendederrorinformation,call
GetLastError.ThefunctionfailsifyouspecifyaninvalidvalueforthedwOSVersionInfoSizememberoftheOSVERSIONINFOorOSVERSIONINFOEXstructure.
Remarks
WhenusingtheGetVersionExfunctiontodeterminewhetheryourapplicationisrunningonaparticularversionoftheoperatingsystem,checkforversionnumbersthataregreaterthanorequaltothedesiredversionnumbers.Thisensuresthatthetestsucceedsforlaterversionsoftheoperatingsystem.Forexample,ifyourapplicationrequiresWindows98,usethefollowingtest:
GetVersionEx(&osvi);
bIsWindows98orLater=
(osvi.dwPlatformId==VER_PLATFORM_WIN32_WINDOWS)&&
((osvi.dwMajorVersion>4)||
((osvi.dwMajorVersion==4)&&(osvi.dwMinorVersion>0)));
Identifyingthecurrentoperatingsystemisusuallynotthebestwaytodeterminewhetheraparticularoperatingsystemfeatureispresent.ThisisbecausetheoperatingsystemmayhavehadnewfeaturesaddedinaredistributableDLL.RatherthanusingGetVersionExtodeterminetheoperatingsystemplatformorversionnumber,testforthepresenceofthefeatureitself.
Todeterminethebestwaytotestforafeature,refertothedocumentationforthefeatureofinterest.Thefollowinglistdiscussessomecommontechniquesforfeaturedetection:
∙Youcantestforthepresenceofthefunctionsassociatedwithafeature.TotestforthepresenceofafunctioninasystemDLL,callthe
LoadLibraryfunctiontoloadtheDLL.Thencallthe
GetProcAddressfunctiontodeterminewhetherthefunctionofinterestispresentintheDLL.UsethepointerreturnedbyGetProcAddresstocallthefunction.Notethatevenifthefunctionispresent,itmaybeastubthatjustreturnsanerrorcodesuchasERROR_CALL_NOT_IMPLEMENTED.
∙YoucandeterminethepresenceofsomefeaturesbyusingtheGetSystemMetricsfunction.Forexample,youcandetectmultipledisplaymonitorsbycallingGetSystemMetrics(SM_CMONITORS).
∙ThereareseveralversionsoftheredistributableDLLsthatimplementshellandcommoncontrolfeatures.Forinformationaboutdeterminingwhichversionsarepresentonthesystemyourapplicationisrunningon,seethetopic
ShellVersions.
WindowsCE:
ThevalueofthedwPlatformIDmemberoftheOSVERSIONINFOstructurewillbeVER_PLATFORM_WIN32_CE.
QuickInfo
WindowsNT:
Requiresversion3.5orlater.
Windows:
RequiresWindows95orlater.
WindowsCE:
Requiresversion1.0orlater.
Header:
Declaredinwinbase.h.
ImportLibrary:
Usekernel32.lib.
Unicode:
ImplementedasUnicodeandANSIversionsonWindowsNT.
GetPriorityClass
TheGetPriorityClassfunctionreturnsthepriorityclassforthespecifiedprocess.Thisvalue,togetherwiththepriorityvalueofeachthreadoftheprocess,determineseachthread'sbaseprioritylevel.
DWORDGetPriorityClass(
HANDLEhProcess//handletotheprocess
);
Parameters
hProcess
Handletotheprocess.
WindowsNT:
ThehandlemusthavePROCESS_QUERY_INFORMATIONaccess.
ReturnValues
Ifthefunctionsucceeds,thereturnvalueisthepriorityclassofthespecifiedprocess.
Ifthefunctionfails,thereturnvalueiszero.Togetextendederrorinformation,callGetLastError.
Theprocess'spriorityclassisoneofthefollowingvalues:
Priority
Meaning
HIGH_PRIORITY_CLASS
Indicatesaprocessthatperformstime-criticaltasksthatmustbeexecutedimmediatelyforittoruncorrectly.Thethreadsofahigh-priorityclassprocesspreemptthethreadsofnormaloridlepriorityclassprocesses.AnexampleistheTaskList,whichmustrespondquicklywhencalledbytheuser,regardlessoftheloadontheoperatingsystem.Useextremecarewhenusingthehigh-priorityclass,becauseahigh-priorityclassCPU-boundapplicationcanusenearlyallavailablecycles.
IDLE_PRIORITY_CLASS
Indicatesaprocesswhosethreadsrunonlywhenthesystemisidleandarepreemptedbythethreadsofanyprocessrunninginahigherpriorityclass.Anexampleisascreensaver.Theidlepriorityclassisinheritedbychildprocesses.
NORMAL_PRIORITY_CLASS
Indicatesanormalprocesswithnospecialschedulingneeds.
REALTIME_PRIORITY_CLASS
Indicatesaprocessthathasthehighestpossiblepriority.Thethreadsofareal-timepriorityclassprocesspreemptthethreadsofallotherprocesses,includingoperatingsystemprocessesperformingimportanttasks.Forexample,areal-timeprocessthatexecutesformorethanaverybriefintervalcancausediskcachesnottoflushorcausethemousetobeunresponsive.
Remarks
Everythreadhasabasepriorityleveldeterminedbythethread'spriorityvalueandthepriorityclassofitsprocess.TheoperatingsystemusesthebaseprioritylevelofallexecutablethreadstodeterminewhichthreadgetsthenextsliceofCPUtime.Threadsarescheduledinaround-robinfashionateachprioritylevel,andonlywhentherearenoexecutablethreadsatahigherlevelwillschedulingofthreadsatalowerleveltakeplace.
Foratablethatshowsthebaseprioritylevelsforeachcombinationofpriorityclassandthreadpriorityvalue,seetheSetPriorityClassfunction.
QuickInfo
WindowsNT:
Requiresversion3.1orlater.
Windows:
RequiresWindows95orlater.
WindowsCE:
Unsupported.
Header:
Declaredinwinbase.h.
ImportLibrar