1、Standard ECMA-234December 1995Standardizing Information and Communication SystemsPhone: +41 22 849.60.00 - Fax: +41 22 849.60.01 - URL: http:/www.ecma.ch - Internet: helpdeskecma.chApplication ProgrammingInterface for WindowsVolume 2Section 4 - System ServicesSection 5 - Application Support Function
2、sStandard ECMA-234December 1995Standardizing Information and Communication SystemsPhone: +41 22 849.60.00 - Fax: +41 22 849.60.01 - URL: http:/www.ecma.ch - Internet: helpdeskecma.chGL E-234-V2.DOC 07-03-96 15,54Application ProgrammingInterface for WindowsBrief HistoryThe APIW Standard is a function
3、al specification of the Microsoft Windows 3.1 application programming interface. It is basedon existing implementations (including Microsoft and others) and behavior. The goal of writing this specification is to define anenvironment in which: applications written to this baseline will be portable to
4、 all implementations of the APIW Standard. the interface can be enriched through open standards processes to meet current and future user needs in a timely fashion.APIW uses the current C language binding, and reflects existing coding practices to ensure that current applications willconform to this
5、 standard. The APIs documented in this standard shall accurately reflect existing implementations of thewindows APIs. If an application that runs with an existing implementation uses one or more APIs contrary to the way it isdescribed in the standard, the standard will be changed to accurately refle
6、ct the behavior.The APIW Standard defines a set of application programming interfaces that allow for the creation of graphical applicationsspanning a wide range of capabilities. The standard groups these APIs into major functional areas including a window managerinterface, a graphics device interfac
7、e and interfaces necessary for accessing system resources and capabilities. The APIrequirements of todays major desktop applications are reflected in this specification and are the criteria for determining theAPIW content.The APIW Standard focuses on providing the necessary APIs for writing applicat
8、ions for the desktop, and also allowsadditional APIs to be bound to an application. This feature enables services outside the scope of a standard desktop applicationto be provided, for example, database, networking or other system services.The APIW Standard defines the basic graphical use interface
9、objects, such as buttons, scrollbars, menus, static and editcontrols, and the painting functions to draw them, such as area fill, and line and rectangle drawing. Finally, a rich set of textroutines in defined, from simple text output to more complex text output routines using multiple founts and fon
10、t styles, allsupporting the use of color.The APIW Standard is documented in five sections, corresponding loosely to the four functional subsystems represented by theAPI and the conformance clause. The four APIW sections cover window management, graphical interface, system services andan application
11、support services section. These functions cover window creation and management, graphics routines to paint textand other graphics objects in those windows, functions to access system resources such as files and timers, and finally, commonsupport functions to accelerate the development of graphical w
12、indow-based applications.The APIW Window Subsystem section of the standard covers the creation, deletion and management of the window, includingwindow positioning and sizing and the sending and receiving of messages. Within each of these window managementsubsections are routines that significantly e
13、xtend the basic functions. With window creation, there are many types of windowsthat can be created including built-in classes and user-definable classes, that have the ability to modify the style of any one ofthe built-in classes. Additional functions are defined to affect the display of a window,
14、including functions to modify thewindows menu, scrollbars, and the display of carets or cursors within the window. With multiple overlapped windows beingdisplayed simultaneously, functions are defined to manage the position and size of those windows, as well as to control thevisibility of a window a
15、nd its associated icon when it is minimized.The APIW Window Subsystem section also defines a set of functions for managing a subset of the user interface, referred to asdialog boxes. These functions allow for the creation and management of the dialog box, as well as the user interaction with thedial
16、og box up to its closure. Utility functions are defined to make designing and using a dialog box easier. These utilitiesprovide common dialog box functions, such as group boxes and check boxes, as well as file interface functions to list files anddirectories. Each of these dialog boxes are controlle
17、d by the use of dialog box templates that are stored in resource files.The APIW Graphics Subsystem section covers all aspects of actually drawing in a window. These aspects include line drawing,text output, graphics primitives, such as rectangles and ellipses, as well as more sophisticated routines
18、such as floodfill(),bitblts() and stretchblt(). The Graphics Device Interface defines bitmaps, icons, cursors and carets, as well as functions toprovide for a portable graphics file format called metafiles. The Graphics Device Interface defines a logical coordinate space tofurther abstract the under
19、lying hardware and has functions to map between the logical and physical coordinate space. TheGraphics Device Interface defines utility functions for all drawing routines that use pens, brushes and regions to get precisecontrol over how graphical objects will be drawn.The APIW System Services sectio
20、n defines platform-independent routines for an application to query the system environmentand access system services. System services that may be accessed include memory, timers, the keyboard and the native filesystem. There are subsections that deal with resources, device I/O and system diagnostic
21、routines. Resource managementallows for the loading and unloading of user- and system-defined resources, such as icons, bitmaps and strings. Device I/Oincludes both parallel and serial port input and output operations. System diagnostic routines enable an application ordiagnostic tool to examine the
22、 state of an application, including memory utilization, task information and stack usage.The APIW Application Support Function section defines miscellaneous functions that can be used by a developer in anapplication. These utility functions define built-in services that a developer does not have to
23、rewrite with each application.These service functions include debugging routines and simple user interface routines to provide graphical feedback to a user.They also include routines for file compression and decompression, standardized routines to retrieve application versioninformation and routines
24、 to manage initialization files.Adopted as an ECMA Standard by the General Assembly of December 1995.- i -Table of contentsSection 4 - System Services 1305 GetFreeSystemResources 1306 SystemParametersInfo 1307 GetWinFlags 6308 GetSystemMetrics 7309 GetVersion 8310 SetTimer, TimerProc, KillTimer 9311
25、 SetDoubleClickTime, GetDoubleClickTime 9312 GetTickCount, GetCurrentTime 10313 GetTimerResolution 10314 LoadLibrary, FreeLibrary 11315 LoadModule, FreeModule 11316 GetModuleFileName, GetModuleHandle, GetModuleUsage 13317 GetProcAddress 13318 MakeProcInstance, FreeProcInstance 14319 LibMain 14320 WE
26、P 15321 GetInstanceData 15322 GetFreeSpace 16323 GlobalAlloc, GlobalFree, LocalAlloc, LocalFree 16324 GlobalCompact, LocalCompact 17325 GlobalFix, GlobalUnfix 17326 GlobalFlags, LocalFlags 18327 GlobalHandle, LocalHandle 18328 GlobalLock, GlobalUnlock, LocalLock, LocalUnlock 19329 GlobalLRUNewest, G
27、lobalLRUOldest 19330 GlobalNotify, NotifyProc 20331 GlobalReAlloc 20332 GlobalSize, LocalSize 21333 LocalInit, LocalShrink 21334 Catch, Throw 22335 Yield, DirectedYield 22336 GetCurrentTask 23337 GetNumTasks 23338 GetWindowTask 23339 IsTask 24340 WinHelp 24341 EnumTaskWindows, EnumTaskWndProc 25342
28、WinExec 26343 WinMain 26344 ExitWindows 27345 GetAsyncKeyState 27346 qGetInputState 28- ii -347 GetKeyboardState, SetKeyboardState 28348 GetKeyNameText 29349 GetKeyState 29350 GetKBCodePage 30351 OemKeyScan 30352 MapVirtualKey 31353 VkKeyScan 31354 SwapMouseButton 32355 GetKeyboardType 32356 FindRes
29、ource 33357 LoadResource, FreeResource 34358 LockResource 35359 LoadString 35360 LoadIcon 35361 LoadBitmap 36362 SetResourceHandler, LoadProc 37363 SizeofResource 38364 LoadMenu 38365 LoadMenuIndirect 38366 LoadAccelerators 39367 AllocResource 39368 BuildCommDCB 39369 ClearCommBreak, SetCommBreak 40
30、370 CloseComm, OpenComm 40371 EnableCommNotification 41372 EscapeCommFunction 42373 FlushComm 43374 GetCommError 44375 GetCommEventMask, SetCommEventMask 45376 GetCommState, SetCommState 46377 ReadComm, WriteComm 47378 TransmitCommChar, UngetCommChar 47379 GetDriveType 48380 GetSystemDirectory 48381
31、 GetTempDrive 49382 GetTempFileName 49383 GetWindowsDirectory 50384 OpenFile 50385 SetHandleCount 52386 _lclose 52387 _lread 52388 _lcreat 53389 _llseek 53390 _lopen 54- iii -391 _lwrite 55392 RegCloseKey 55393 RegCreateKey, RegOpenKey 55394 RegDeleteKey 56395 RegEnumKey 56396 RegQueryValue, RegSetV
32、alue 57397 IsBadCodePtr 57398 IsBadHugeReadPtr 57399 IsBadHugeWritePtr 58400 IsBadReadPtr 58401 IsBadStringPtr 58402 IsBadWritePtr 59Section 5 - Application Support Functions 60403 ExtractIcon 60404 FindExecutable 60405 GetPrivateProfileString, GetProfileString 61406 WritePrivateProfileString, Write
33、ProfileString 62407 GetPrivateProfileInt, GetProfileInt 62408 AnsiLower, AnsiLowerBuff 63409 AnsiUpper, AnsiUpperBuff 63410 AnsiNext, AnsiPrev 64411 IsCharAlpha 64412 IsCharAlphaNumeric 64413 IsCharLower 65414 IsCharUpper 65415 lstrcmp, lstrcmpi 65416 lstrcat, lstrcpy, lstrcpyn 66417 lstrlen 66418 w
34、sprintf, wvsprintf 66419 IsDBCSLeadByte 67420 ToAscii 68421 AnsiToOem, AnsiToOemBuff 68422 OemToAnsi, OemToAnsiBuff 69423 CopyRect, SetRect, SetRectEmpty, InflateRect, OffsetRect 69424 EqualRect, IsRectEmpty, PtInRect 70425 IntersectRect, UnionRect, SubtractRect 71426 OutputDebugString 71427 DebugOu
35、tput 72428 FatalAppExit 72429 FatalExit 72430 QuerySendMessage 73431 LockInput 73432 FlashWindow 74433 MessageBeep 74- iv -434 MessageBox 74435 SetErrorMode 76436 GetExpandedName 76437 ChooseColor 77438 ChooseFont 78439 FindText, ReplaceText 80440 GetOpenFileName, GetSaveFileName 82441 GetFileTitle
36、85442 PrintDlg 85443 CommDlgExtendedError 86444 MulDiv 87Section 4 - System Services305 GetFreeSystemResources305.1 SynopsisUINT GetFreeSystemResources(UINT ResourceType)305.2 DescriptionThe GetFreeSystemResources() function determines the percentage of free space available for all system resourceso
37、r a system resource of a specific type. An application should not use this function to determine if it is possible tocreate a new resource object.The resource type is specified in the ResourceType parameter and can be one of the following defined values:GFSR_SYSTEMRESOURCES This value specifies all
38、system resources.GFSR_USERRESOURCES This value specifies USER resources; window and menu handles areconsidered USER resources.GFSR_GDIRESOURCES This value specifies GDI resources; device-context handles, brushes,pens, regions, fonts, and bitmaps are considered GDI resources.305.3 ReturnsThe GetFreeS
39、ystemResources() function returns the percentage of free space available for the system resourceindicated.305.4 ErrorsNone.305.5 Cross-ReferencesNone.306 SystemParametersInfo306.1 SynopsisBOOL SystemParametersInfo(UINT Operation, UINT Data1,void *Data2, UINT UpdateFlag);306.2 DescriptionThe SystemPa
40、rametersInfo() function gets or sets a specific type of system information. The type of systeminformation and the operation performed on that information is specified in the functions Operation parameter. Thefunctions Data1 and Data2 parameters contain data unique to the operation being performed.If
41、 the operation sets system information, the function uses the UpdateFlag parameter to determine if the change tothe system information should be saved to the WIN.INI file. The value of the UpdateFlag parameter can be zero toindicate that the WIN.INI file should not be updated or it can be one or mor
42、e of the following values ORedtogether:SPIF_UPDATEINIFILE This value updates the WIN.INI file.SPIF_SENDWININICHANGE This value broadcasts the WM_WININICHANGE message to all top-level windows; valid only when used in combination with theSPIF_UPDATEINIFILE value.The following table contains the allowa
43、ble values for the Command parameter and a description of its function:- 2 -Beep Sound ValueSPI_GETBEEP This value determines if the warning beep is set to on or off.SPI_SETBEEP This value sets the warning beep to on or off.Window Border ValueSPI_GETBORDER This value gets the border multiplying fact
44、or that is used whencalculating the width of a windows sizing border.SPI_SETBORDER This value sets the border multiplying factor that is used whencalculating the width of a windows sizing border.Task Switching ValueSPI_GETFASTTASKSWITCH This value determines if the fast task switching option is set
45、on oroff.SPI_SETFASTTASKSWITCH This value turns the fast task switching option on or off.Desktop ValueSPI_GETGRIDGRANULARITY This value gets the granularity value for the desktops sizing grid.SPI_SETGRIDGRANULARITY This value sets the granularity value for the desktops sizing grid.SPI_SETDESKPATTERN
46、 This value sets the desktop pattern.SPI_SETDESKWALLPAPER This value sets the bitmap used for the desktop wallpaper.Icons ValueSPI_GETICONTITLELOGFONT This value gets the font information for the current font used to drawicon titles.SPI_SETICONTITLELOGFONT This value sets the font that is used for d
47、rawing icon titles.SPI_GETICONTITLEWRAP This value determines if icon title word wrapping is set to on or off.SPI_SETICONTITLEWRAP This value sets the icon title word wrapping option on or off.SPI_ICONHORIZONTALSPACING This value sets the number of pixels in an icons cell width.SPI_ICONVERTICALSPACI
48、NG This value sets the number of pixels in an icons cell height.Keyboard ValueSPI_GETKEYBOARDDELAY This value gets the keyboards repeat-delay valueSPI_SETKEYBOARDDELAY This value sets the keyboards repeat-delay value.SPI_GETKEYBOARDSPEED This value gets the keyboards repeat-speed value.SPI_SETKEYBOA
49、RDSPEED This value sets the keyboards repeat-speed value.Menus ValueSPI_GETMENUDROPALIGNMENT This value determines if pop-up menus are aligned to the left or rightof its menu-bar item. Sets how pop-up menus are aligned relative toits menu-bar item.SPI_SETMENUDROPALIGNMENT This value sets how pop-up menus are aligned relative to its menu-bar item.Mouse Gets the mouse speed and the mouse threshold values.SPI_GETMOUSE This value gets the mouse speed and the mouse threshold values.- 3 -SPI_SETMOUSE This value sets the mouse speed and the mouse threshold values.SPI_SETDOUBLECL