ebook img

The Tomes of Delphi - Win32 Shell API PDF

774 Pages·1999·8.31 MB·English
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview The Tomes of Delphi - Win32 Shell API

Y L F M A E T Team-Fly® The Tomes of Delphi™ Win32 Shell API Windows 2000 Edition John Ayres Wordware Publishing, Inc. LibraryofCongressCataloging-in-PublicationData Ayres,John. TomesofDelphi:Win32ShellAPI—Windows2000edition/byJohnAyres. p. cm. Includesindex. ISBN 1-55622-749-3(paperback) 1. MicrosoftWin32. 2. Delphi(Computerfile). I. Title. QA76.76.063A98 2002 005.265--dc21 2002004006 CIP ©2002,WordwarePublishing,Inc. AllRightsReserved 2320LosRiosBoulevard Plano,Texas75074 Nopartofthisbookmaybereproducedinanyformorby anymeanswithoutpermissioninwritingfrom WordwarePublishing,Inc. PrintedintheUnitedStatesofAmerica ISBN1-55622-749-3 10 9 8 7 6 5 4 3 2 1 0204 DelphiisatrademarkofBorlandSoftwareCorporationintheUnitedStatesandothercountries.Windowsisaregistered trademarkofMicrosoftCorporationintheUnitedStatesand/orothercountries.Otherproductsmentionedareusedfor identificationpurposesonlyandmaybetrademarksoftheirrespectivecompanies. AllinquiriesforvolumepurchasesofthisbookshouldbeaddressedtoWordwarePublishing,Inc.,atthe aboveaddress.Telephoneinquiriesmaybemadebycalling: (972)423-0090 Praise for John Ayres’ books Tomes of Delphi “TheTomesofDelphiisthedefinitivereferencefortheWin32APIexpressed intheObjectPascallanguage.It’samust-haveforapplicationandcomponent developerslookingtoextendtheirreachbeyondthecapabilitiesoftheVisual ComponentLibrary.” SteveTeixeira,DirectorCoreTechnology ZoneLabs,Inc.andco-authorofDelphi6Developer’sGuide *************************** “Delphiletsdeveloperswork‘underthehood’withtheWin32API.TheTomes ofDelphi3:Win32CoreAPIgiveseveryDelphidevelopertheknowledgeto usetheWin32APIpowerfully,creatively,andeffectively.” MichaelSwindell,DirectorofProductManagement RADToolsGroup,BorlandSoftwareCorporation *************************** “TheTomesofDelphi3:Win32CoreAPIismynumberoneresourcewhen lookingforinformationabouthowtousetheWin32coreAPIinDelphi.Iespe- ciallyenjoythehelpfilethatcontainsthecompletetextfromthebookandcan beaccesseddirectlywhenprogramming.” BobSwart(a.k.a.“Dr.Bob”),Author,trainer,consultant *************************** “NotonlywerethesethefirstDelphibookstoconcentrateonAPI-levelpro- gramming,theysetthestandardforallfutureDelphiAPIbooks.Withthe increasingimportanceoftheshellAPIforWindowsdevelopers,thisistheper- fectupdateforthisclassicDelphiwork.” AlanC.Moore,ContributingEditor DelphiInformantMagazine Dedication Tomyseconddaughter,VictoriaAnnAyres.Theentiretyofthisbookwaswritten whilesheandhermotherwerestillapartofeachother.Asthatmiraculousday approacheswhenIcanfinallymeetherfacetofaceandwelcomehertoourworld,my panicisslowlybeingreplacedwithincrediblejoyandwonder.Childrenareindeeda miracle,andIamverythankfulforthisgiftfromGodthatweshallsoonreceive.The responsibilityofparenthoodcanbedemandingattimes,butitisveryrewarding,andI amdoublyblessedfortheopportunitytoonceagainshapethefutureofonewhoissure togrowintoanincredibleperson.Hero,mentor,rolemodel,playmate,dancepartner, confidant,keeperofsecrets,andhealerofwounds—allthesethingsandmuch,much moreadduptofatherhood.Ihopetoliveuptomydaughter’sexpectationsofafather, andmayshegrowtobemorethanthesumofherparents. Contents Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii Acknowledgments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi Chapter1 Delphi and the Windows API. . . . . . . . . . . . . . . . . . . . 1 WindowsDataTypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Handles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Constants. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 ImportingWindowsFunctions . . . . . . . . . . . . . . . . . . . . . . . . 4 IncorrectlyImportedFunctions . . . . . . . . . . . . . . . . . . . . . . 5 CallbackFunctions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 FunctionParameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Unicode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Delphivs.theWindowsAPI . . . . . . . . . . . . . . . . . . . . . . . . . 7 Chapter2 Window Movement Functions . . . . . . . . . . . . . . . . . . . 9 Z-order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 SpecialEffects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Delphivs.theWindowsAPI. . . . . . . . . . . . . . . . . . . . . . . . . 11 WindowMovementFunctions . . . . . . . . . . . . . . . . . . . . . . . . 12 AdjustWindowRect. . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 AdjustWindowRectEx . . . . . . . . . . . . . . . . . . . . . . . . . . 14 BeginDeferWindowPos . . . . . . . . . . . . . . . . . . . . . . . . . 15 BringWindowToTop . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 CascadeWindows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 CloseWindow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 DeferWindowPos. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 EndDeferWindowPos . . . . . . . . . . . . . . . . . . . . . . . . . . 23 GetWindowPlacement . . . . . . . . . . . . . . . . . . . . . . . . . . 23 MoveWindow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 OpenIcon. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 SetWindowPlacement . . . . . . . . . . . . . . . . . . . . . . . . . . 26 SetWindowPos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 v Contents ShowOwnedPopups . . . . . . . . . . . . . . . . . . . . . . . . . . 32 ShowWindow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 ShowWindowAsync . . . . . . . . . . . . . . . . . . . . . . . . . . 35 TileWindows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Chapter3 Window Information Functions . . . . . . . . . . . . . . . . . . 39 InformationStorage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Window-specificInformation . . . . . . . . . . . . . . . . . . . . . . . . 40 SubclassingaWindow . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 KnowingItAll . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Delphivs.theWindowsAPI. . . . . . . . . . . . . . . . . . . . . . . . . 48 WindowInformationFunctions . . . . . . . . . . . . . . . . . . . . . . . 49 AnyPopup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 ChildWindowFromPoint. . . . . . . . . . . . . . . . . . . . . . . . 51 ChildWindowFromPointEx . . . . . . . . . . . . . . . . . . . . . . 52 EnableWindow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 EnumChildWindows. . . . . . . . . . . . . . . . . . . . . . . . . . 55 EnumProps. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 EnumPropsEx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 EnumThreadWindows . . . . . . . . . . . . . . . . . . . . . . . . . 63 EnumWindows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 FindWindow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 FindWindowEx. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 FlashWindow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 GetActiveWindow . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 GetClassInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 GetClassInfoEx . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 GetClassLong . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 GetClassName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 GetClientRect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 GetDesktopWindow . . . . . . . . . . . . . . . . . . . . . . . . . . 79 GetFocus. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 GetForegroundWindow . . . . . . . . . . . . . . . . . . . . . . . . 80 GetNextWindow . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 GetParent. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 GetProp. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 GetTopWindow . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 GetWindow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 GetWindowLong. . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 GetWindowRect . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 GetWindowText . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 GetWindowTextLength . . . . . . . . . . . . . . . . . . . . . . . . 92 IsChild . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 IsIconic. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 IsWindow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 vi Contents IsWindowEnabled . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 IsWindowUnicode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 IsWindowVisible. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 IsZoomed. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 RemoveProp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 SetActiveWindow . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 SetClassLong. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 SetFocus. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 SetForegroundWindow . . . . . . . . . . . . . . . . . . . . . . . . . 102 SetParent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 SetProp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 SetWindowLong . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 SetWindowText. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 WindowFromPoint . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 Chapter4 File Input/Output Functions . . . . . . . . . . . . . . . . . . . 109 FileCreation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 FileTimes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 Delphivs.theWindowsAPI . . . . . . . . . . . . . . . . . . . . . . . . 110 FileInput/OutputFunctions. . . . . . . . . . . . . . . . . . . . . . . . . 111 CloseHandle. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 CompareFileTime. . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 CopyFile. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 CreateDirectory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 CreateDirectoryEx . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 CreateFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 CreateFileMapping . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 DeleteFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 DosDateTimeToFileTime. . . . . . . . . . . . . . . . . . . . . . . . 133 FileTimeToDosDateTime. . . . . . . . . . . . . . . . . . . . . . . . 134 FileTimeToLocalFileTime . . . . . . . . . . . . . . . . . . . . . . . 135 FileTimeToSystemTime . . . . . . . . . . . . . . . . . . . . . . . . 135 FindClose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 FindCloseChangeNotification . . . . . . . . . . . . . . . . . . . . . 140 FindFirstChangeNotification . . . . . . . . . . . . . . . . . . . . . . 141 FindFirstFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 FindNextChangeNotification. . . . . . . . . . . . . . . . . . . . . . 147 FindNextFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 FlushFileBuffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 FlushViewOfFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 GetCurrentDirectory . . . . . . . . . . . . . . . . . . . . . . . . . . 150 GetFileAttributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 GetFileInformationByHandle. . . . . . . . . . . . . . . . . . . . . . 152 GetFileSize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 GetFileTime. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 vii Contents GetFileType. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 GetFileVersionInfo . . . . . . . . . . . . . . . . . . . . . . . . . . 157 GetFileVersionInfoSize. . . . . . . . . . . . . . . . . . . . . . . . 158 GetFullPathName. . . . . . . . . . . . . . . . . . . . . . . . . . . 159 GetShortPathName . . . . . . . . . . . . . . . . . . . . . . . . . . 159 GetTempFileName . . . . . . . . . . . . . . . . . . . . . . . . . . 160 GetTempPath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 LocalFileTimeToFileTime . . . . . . . . . . . . . . . . . . . . . . 163 LockFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 MapViewOfFile. . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 MoveFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 OpenFileMapping. . . . . . . . . . . . . . . . . . . . . . . . . . . 167 ReadFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 RemoveDirectory. . . . . . . . . . . . . . . . . . . . . . . . . . . 170 SearchPath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 SetCurrentDirectory . . . . . . . . . . . . . . . . . . . . . . . . . 171 SetEndOfFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 SetFileAttributes . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 SetFilePointer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 SetFileTime. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 SystemTimeToFileTime . . . . . . . . . . . . . . . . . . . . . . . 179 UnlockFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 UnMapViewOfFile . . . . . . . . . . . . . . . . . . . . . . . . . . 181 VerQueryValue . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 WriteFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 Chapter5 Input Functions. . . . . . . . . . . . . . . . . . . . . . . . . . 191 TheKeyboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 TheMouse. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 Delphivs.theWindowsAPI . . . . . . . . . . . . . . . . . . . . . . . . 192 InputFunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 ActivateKeyboardLayout. . . . . . . . . . . . . . . . . . . . . . . 194 ClipCursor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 DragDetect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 GetAsyncKeyState . . . . . . . . . . . . . . . . . . . . . . . . . . 197 GetCapture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 GetCaretBlinkTime. . . . . . . . . . . . . . . . . . . . . . . . . . 198 GetCaretPos. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 GetClipCursor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 GetCursorPos. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 GetDoubleClickTime. . . . . . . . . . . . . . . . . . . . . . . . . 200 GetInputState . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 GetKeyboardLayout . . . . . . . . . . . . . . . . . . . . . . . . . 201 GetKeyboardLayoutList . . . . . . . . . . . . . . . . . . . . . . . 202 GetKeyboardLayoutName . . . . . . . . . . . . . . . . . . . . . . 202 viii Contents GetKeyboardState. . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 GetKeyboardType. . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 GetKeyNameText. . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 GetKeyState. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 keybd_event. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 joyGetDevCaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 joyGetNumDevs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 joyGetPos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 joyGetPosEx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 joyGetThreshold . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 joyReleaseCapture . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 joySetCapture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 joySetThreshold. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 LoadKeyboardLayout. . . . . . . . . . . . . . . . . . . . . . . . . . 225 MapVirtualKey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 MapVirtualKeyEx. . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 mouse_event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 OEMKeyScan. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234 ReleaseCapture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 SetCapture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 SetCaretBlinkTime . . . . . . . . . . . . . . . . . . . . . . . . . . . 236 SetCaretPos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 SetCursorPos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 SetDoubleClickTime . . . . . . . . . . . . . . . . . . . . . . . . . . 239 SetKeyboardState. . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 SwapMouseButton . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 UnloadKeyboardLayout . . . . . . . . . . . . . . . . . . . . . . . . 244 VkKeyScan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244 VkKeyScanEx. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 Chapter6 String and Atom Functions . . . . . . . . . . . . . . . . . . . 249 AtomTables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 StringFormatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 Delphivs.theWindowsAPI . . . . . . . . . . . . . . . . . . . . . . . . 250 StringandAtomFunctions . . . . . . . . . . . . . . . . . . . . . . . . . 251 AddAtom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 CharLower . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253 CharLowerBuff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 CharNext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256 CharPrev . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 CharToOem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 CharToOemBuff . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 CharUpper. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 CharUpperBuff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260 CompareString . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 ix

Description:
“The Tomes of Delphi is the definitive reference for the Win32 API expressed in the Object Pascal language. It's a must-have for application and component developers looking to extend their reach beyond the capabilities of the Visual. Component Library.” Steve Teixeira, Director Core Technology
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.