dwmapi.pp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2009 by the Free Pascal development team
  4. member of the Free Pascal development team.
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {*=========================================================================*
  12. Copyright (c) Microsoft Corporation. All rights reserved.
  13. File: dwmapi.h
  14. Module Name: dwmapi
  15. Description: DWM API declarations
  16. *=========================================================================*}
  17. {$IFNDEF FPC_DOTTEDUNITS}
  18. unit DwmApi;
  19. {$ENDIF FPC_DOTTEDUNITS}
  20. {$mode objfpc}{$H+}
  21. interface
  22. {$IFDEF FPC_DOTTEDUNITS}
  23. uses
  24. WinApi.Windows, WinApi.Uxtheme;
  25. {$ELSE FPC_DOTTEDUNITS}
  26. uses
  27. Windows, UxTheme;
  28. {$ENDIF FPC_DOTTEDUNITS}
  29. procedure FreeDwmLibrary;
  30. function InitDwmLibrary: Boolean;
  31. function DwmCompositionEnabled: Boolean;
  32. // Blur behind data structures
  33. const
  34. DWM_BB_ENABLE = $00000001; // fEnable has been specified
  35. DWM_BB_BLURREGION = $00000002; // hRgnBlur has been specified
  36. DWM_BB_TRANSITIONONMAXIMIZED = $00000004; // fTransitionOnMaximized has been specified
  37. type
  38. _DWM_BLURBEHIND = record
  39. dwFlags: DWORD;
  40. fEnable: BOOL;
  41. hRgnBlur: HRGN;
  42. fTransitionOnMaximized: BOOL;
  43. end;
  44. DWM_BLURBEHIND = _DWM_BLURBEHIND;
  45. PDWM_BLURBEHIND = ^_DWM_BLURBEHIND;
  46. TDWMBlurBehind = DWM_BLURBEHIND;
  47. PDWMBlurBehind = PDWM_BLURBEHIND;
  48. // Window attributes
  49. const
  50. DWMWA_NCRENDERING_ENABLED = 01; // [get] Is non-client rendering enabled/disabled
  51. DWMWA_NCRENDERING_POLICY = 02; // [set] Non-client rendering policy
  52. DWMWA_TRANSITIONS_FORCEDISABLED = 03; // [set] Potentially enable/forcibly disable transitions
  53. DWMWA_ALLOW_NCPAINT = 04; // [set] Allow contents rendered in the non-client area to be visible on the DWM-drawn frame.
  54. DWMWA_CAPTION_BUTTON_BOUNDS = 05; // [get] Bounds of the caption button area in window-relative space.
  55. DWMWA_NONCLIENT_RTL_LAYOUT = 06; // [set] Is non-client content RTL mirrored
  56. DWMWA_FORCE_ICONIC_REPRESENTATION = 07; // [set] Force this window to display iconic thumbnails.
  57. DWMWA_FLIP3D_POLICY = 08; // [set] Designates how Flip3D will treat the window.
  58. DWMWA_EXTENDED_FRAME_BOUNDS = 09; // [get] Gets the extended frame bounds rectangle in screen space
  59. DWMWA_HAS_ICONIC_BITMAP = 10; // [set] Indicates an available bitmap when there is no better thumbnail representation.
  60. DWMWA_DISALLOW_PEEK = 11; // [set] Don't invoke Peek on the window.
  61. DWMWA_EXCLUDED_FROM_PEEK = 12; // [set] LivePreview exclusion information
  62. DWMWA_CLOAK = 13; // [set] Cloak or uncloak the window
  63. DWMWA_CLOAKED = 14; // [get] Gets the cloaked state of the window
  64. DWMWA_FREEZE_REPRESENTATION = 15; // [set] BOOL, Force this window to freeze the thumbnail without live update
  65. DWMWA_PASSIVE_UPDATE_MODE = 16; // [set] BOOL, Updates the window only when desktop composition runs for other reasons
  66. DWMWA_USE_HOSTBACKDROPBRUSH = 17; // [set] BOOL, Allows the use of host backdrop brushes for the window.
  67. DWMWA_USE_IMMERSIVE_DARK_MODE = 20; // [set] BOOL, Allows a window to either use the accent color, or dark, according to the user Color Mode preferences.
  68. DWMWA_WINDOW_CORNER_PREFERENCE = 33; // [set] WINDOW_CORNER_PREFERENCE, Controls the policy that rounds top-level window corners
  69. DWMWA_BORDER_COLOR = 34; // [set] COLORREF, The color of the thin border around a top-level window
  70. DWMWA_CAPTION_COLOR = 35; // [set] COLORREF, The color of the caption
  71. DWMWA_TEXT_COLOR = 36; // [set] COLORREF, The color of the caption text
  72. DWMWA_VISIBLE_FRAME_BORDER_THICKNESS = 37; // [get] UINT, width of the visible border around a thick frame window
  73. DWMWA_LAST = 38;
  74. // Apply rounded corners in desktop apps for Windows 11
  75. // DWM_WINDOW_CORNER_PREFERENCE
  76. DWMWCP_DEFAULT = 0; // Let the system decide whether or not to round window corners
  77. DWMWCP_DONOTROUND = 1; // Never round window corners
  78. DWMWCP_ROUND = 2; // Round the corners if appropriate
  79. DWMWCP_ROUNDSMALL = 3; // Round the corners if appropriate, with a small radius
  80. // Use this constant to reset any window part colors to the system default behavior
  81. DWMWA_COLOR_DEFAULT = $FFFFFFFF;
  82. // Use this constant to specify that a window part should not be rendered
  83. DWMWA_COLOR_NONE = $FFFFFFFE;
  84. // Non-client rendering policy attribute values
  85. const
  86. DWMNCRP_USEWINDOWSTYLE = 0; // Enable/disable non-client rendering based on window style
  87. DWMNCRP_DISABLED = 1; // Disabled non-client rendering; window style is ignored
  88. DWMNCRP_ENABLED = 2; // Enabled non-client rendering; window style is ignored
  89. DWMNCRP_LAST = 3;
  90. // Values designating how Flip3D treats a given window.
  91. const
  92. DWMFLIP3D_DEFAULT = 0; // Hide or include the window in Flip3D based on window style and visibility.
  93. DWMFLIP3D_EXCLUDEBELOW = 1; // Display the window under Flip3D and disabled.
  94. DWMFLIP3D_EXCLUDEABOVE = 2; // Display the window above Flip3D and enabled.
  95. DWMFLIP3D_LAST = 3;
  96. // Cloaked flags describing why a window is cloaked.
  97. const
  98. DWM_CLOAKED_APP = $00000001;
  99. DWM_CLOAKED_SHELL = $00000002;
  100. DWM_CLOAKED_INHERITED = $00000004;
  101. // Thumbnails
  102. type
  103. HTHUMBNAIL = HANDLE;
  104. PHTHUMBNAIL = ^HTHUMBNAIL;
  105. const
  106. DWM_TNP_RECTDESTINATION = $00000001;
  107. DWM_TNP_RECTSOURCE = $00000002;
  108. DWM_TNP_OPACITY = $00000004;
  109. DWM_TNP_VISIBLE = $00000008;
  110. DWM_TNP_SOURCECLIENTAREAONLY = $00000010;
  111. type
  112. _DWM_THUMBNAIL_PROPERTIES = record
  113. dwFlags: DWORD;
  114. rcDestination: TRect;
  115. rcSource: TRect;
  116. opacity: Byte;
  117. fVisible: BOOL;
  118. fSourceClientAreaOnly: BOOL;
  119. end;
  120. DWM_THUMBNAIL_PROPERTIES = _DWM_THUMBNAIL_PROPERTIES;
  121. PDWM_THUMBNAIL_PROPERTIES = ^_DWM_THUMBNAIL_PROPERTIES;
  122. TDWMThumbnailProperties = DWM_THUMBNAIL_PROPERTIES;
  123. PDWMThumbnailProperties = PDWM_THUMBNAIL_PROPERTIES;
  124. // Video enabling apis
  125. type
  126. DWM_FRAME_COUNT = ULONGLONG;
  127. QPC_TIME = ULONGLONG;
  128. type
  129. _UNSIGNED_RATIO = record
  130. uiNumerator: LongWord;
  131. uiDenominator: LongWord;
  132. end;
  133. UNSIGNED_RATIO = _UNSIGNED_RATIO;
  134. TUnsignedRatio = UNSIGNED_RATIO;
  135. type
  136. _DWM_TIMING_INFO = record
  137. cbSize: LongWord;
  138. // Data on DWM composition overall
  139. // Monitor refresh rate
  140. rateRefresh: UNSIGNED_RATIO;
  141. // Actual period
  142. qpcRefreshPeriod: QPC_TIME;
  143. // composition rate
  144. rateCompose: UNSIGNED_RATIO;
  145. // QPC time at a VSync interupt
  146. qpcVBlank: QPC_TIME;
  147. // DWM refresh count of the last vsync
  148. // DWM refresh count is a 64bit number where zero is
  149. // the first refresh the DWM woke up to process
  150. cRefresh: DWM_FRAME_COUNT;
  151. // DX refresh count at the last Vsync Interupt
  152. // DX refresh count is a 32bit number with zero
  153. // being the first refresh after the card was initialized
  154. // DX increments a counter when ever a VSync ISR is processed
  155. // It is possible for DX to miss VSyncs
  156. //
  157. // There is not a fixed mapping between DX and DWM refresh counts
  158. // because the DX will rollover and may miss VSync interupts
  159. cDXRefresh: UINT;
  160. // QPC time at a compose time.
  161. qpcCompose: QPC_TIME;
  162. // Frame number that was composed at qpcCompose
  163. cFrame: DWM_FRAME_COUNT;
  164. // The present number DX uses to identify renderer frames
  165. cDXPresent: UINT;
  166. // Refresh count of the frame that was composed at qpcCompose
  167. cRefreshFrame: DWM_FRAME_COUNT;
  168. // DWM frame number that was last submitted
  169. cFrameSubmitted: DWM_FRAME_COUNT;
  170. // DX Present number that was last submitted
  171. cDXPresentSubmitted: UINT;
  172. // DWM frame number that was last confirmed presented
  173. cFrameConfirmed: DWM_FRAME_COUNT;
  174. // DX Present number that was last confirmed presented
  175. cDXPresentConfirmed: UINT;
  176. // The target refresh count of the last
  177. // frame confirmed completed by the GPU
  178. cRefreshConfirmed: DWM_FRAME_COUNT;
  179. // DX refresh count when the frame was confirmed presented
  180. cDXRefreshConfirmed: UINT;
  181. // Number of frames the DWM presented late
  182. // AKA Glitches
  183. cFramesLate: DWM_FRAME_COUNT;
  184. // the number of composition frames that
  185. // have been issued but not confirmed completed
  186. cFramesOutstanding: UINT;
  187. // Following fields are only relavent when an HWND is specified
  188. // Display frame
  189. // Last frame displayed
  190. cFrameDisplayed: DWM_FRAME_COUNT;
  191. // QPC time of the composition pass when the frame was displayed
  192. qpcFrameDisplayed: QPC_TIME;
  193. // Count of the VSync when the frame should have become visible
  194. cRefreshFrameDisplayed: DWM_FRAME_COUNT;
  195. // Complete frames: DX has notified the DWM that the frame is done rendering
  196. // ID of the the last frame marked complete (starts at 0)
  197. cFrameComplete: DWM_FRAME_COUNT;
  198. // QPC time when the last frame was marked complete
  199. qpcFrameComplete: QPC_TIME;
  200. // Pending frames:
  201. // The application has been submitted to DX but not completed by the GPU
  202. // ID of the the last frame marked pending (starts at 0)
  203. cFramePending: DWM_FRAME_COUNT;
  204. // QPC time when the last frame was marked pending
  205. qpcFramePending: QPC_TIME;
  206. // number of unique frames displayed
  207. cFramesDisplayed: DWM_FRAME_COUNT;
  208. // number of new completed frames that have been received
  209. cFramesComplete: DWM_FRAME_COUNT;
  210. // number of new frames submitted to DX but not yet complete
  211. cFramesPending: DWM_FRAME_COUNT;
  212. // number of frames available but not displayed, used or dropped
  213. cFramesAvailable: DWM_FRAME_COUNT;
  214. // number of rendered frames that were never
  215. // displayed because composition occurred too late
  216. cFramesDropped: DWM_FRAME_COUNT;
  217. // number of times an old frame was composed
  218. // when a new frame should have been used
  219. // but was not available
  220. cFramesMissed: DWM_FRAME_COUNT;
  221. // the refresh at which the next frame is
  222. // scheduled to be displayed
  223. cRefreshNextDisplayed: DWM_FRAME_COUNT;
  224. // the refresh at which the next DX present is
  225. // scheduled to be displayed
  226. cRefreshNextPresented: DWM_FRAME_COUNT;
  227. // The total number of refreshes worth of content
  228. // for this HWND that have been displayed by the DWM
  229. // since DwmSetPresentParameters was called
  230. cRefreshesDisplayed: DWM_FRAME_COUNT;
  231. // The total number of refreshes worth of content
  232. // that have been presented by the application
  233. // since DwmSetPresentParameters was called
  234. cRefreshesPresented: DWM_FRAME_COUNT;
  235. // The actual refresh # when content for this
  236. // window started to be displayed
  237. // it may be different than that requested
  238. // DwmSetPresentParameters
  239. cRefreshStarted: DWM_FRAME_COUNT;
  240. // Total number of pixels DX redirected
  241. // to the DWM.
  242. // If Queueing is used the full buffer
  243. // is transfered on each present.
  244. // If not queuing it is possible only
  245. // a dirty region is updated
  246. cPixelsReceived: ULONGLONG;
  247. // Total number of pixels drawn.
  248. // Does not take into account if
  249. // if the window is only partial drawn
  250. // do to clipping or dirty rect management
  251. cPixelsDrawn: ULONGLONG;
  252. // The number of buffers in the flipchain
  253. // that are empty. An application can
  254. // present that number of times and guarantee
  255. // it won't be blocked waiting for a buffer to
  256. // become empty to present to
  257. cBuffersEmpty: DWM_FRAME_COUNT;
  258. end;
  259. DWM_TIMING_INFO = _DWM_TIMING_INFO;
  260. TDWMTimingInfo = DWM_TIMING_INFO;
  261. const
  262. // Use the first source frame that
  263. // includes the first refresh of the output frame
  264. DWM_SOURCE_FRAME_SAMPLING_POINT = 0;
  265. // use the source frame that includes the most
  266. // refreshes of out the output frame
  267. // in case of multiple source frames with the
  268. // same coverage the last will be used
  269. DWM_SOURCE_FRAME_SAMPLING_COVERAGE = 1;
  270. // Sentinel value
  271. DWM_SOURCE_FRAME_SAMPLING_LAST = 2;
  272. const
  273. c_DwmMaxQueuedBuffers = 8;
  274. c_DwmMaxMonitors = 16;
  275. c_DwmMaxAdapters = 16;
  276. type
  277. _DWM_PRESENT_PARAMETERS = record
  278. cbSize: LongWord;
  279. fQueue: BOOL;
  280. cRefreshStart: DWM_FRAME_COUNT;
  281. cBuffer: UINT;
  282. fUseSourceRate: BOOL;
  283. rateSource: UNSIGNED_RATIO;
  284. cRefreshesPerFrame: UINT;
  285. eSampling: LongWord;
  286. end;
  287. DWM_PRESENT_PARAMETERS = _DWM_PRESENT_PARAMETERS;
  288. TDWMPresentParameters = DWM_PRESENT_PARAMETERS;
  289. const
  290. DWM_FRAME_DURATION_DEFAULT = -1;
  291. var
  292. DwmDefWindowProc: function(hWnd: HWND; msg: UINT; wParam: WPARAM; lParam: LPARAM; out plResult: LRESULT): BOOL; stdcall;
  293. DwmEnableBlurBehindWindow: function(hWnd: HWND; pBlurBehind: PDWM_BLURBEHIND): HRESULT; stdcall;
  294. const
  295. DWM_EC_DISABLECOMPOSITION = 0;
  296. DWM_EC_ENABLECOMPOSITION = 1;
  297. var
  298. DwmEnableComposition: function(uCompositionAction: UINT): HRESULT; stdcall;
  299. DwmEnableMMCSS: function(fEnableMMCSS: BOOL): HRESULT; stdcall;
  300. DwmExtendFrameIntoClientArea: function(hWnd: HWND; pMarInset: PMARGINS): HRESULT; stdcall;
  301. DwmGetColorizationColor: function(out pcrColorization: DWORD; out pfOpaqueBlend: BOOL): HRESULT; stdcall;
  302. DwmGetCompositionTimingInfo: function(hwnd: HWND; out pTimingInfo: DWM_TIMING_INFO): HRESULT; stdcall;
  303. DwmGetWindowAttribute: function(hwnd: HWND; dwAttribute: DWORD; pvAttribute: Pointer; cbAttribute: DWORD): HRESULT; stdcall;
  304. DwmIsCompositionEnabled: function(out pfEnabled: BOOL): HRESULT; stdcall;
  305. DwmModifyPreviousDxFrameDuration: function(hwnd: HWND; cRefreshes: Integer; fRelative: BOOL): HRESULT; stdcall;
  306. DwmQueryThumbnailSourceSize: function(hThumbnail: HTHUMBNAIL; out pSize: TSIZE): HRESULT; stdcall;
  307. DwmRegisterThumbnail: function(hwndDestination: HWND; hwndSource: HWND; out phThumbnailId: HTHUMBNAIL): HRESULT; stdcall;
  308. DwmSetDxFrameDuration: function(hwnd: HWND; cRefreshes: Integer): HRESULT; stdcall;
  309. DwmSetPresentParameters: function(hwnd: HWND; var pPresentParams: DWM_PRESENT_PARAMETERS): HRESULT; stdcall;
  310. DwmSetWindowAttribute: function(hwnd: HWND; dwAttribute: DWORD; pvAttribute: Pointer; cbAttribute: DWORD): HRESULT; stdcall;
  311. DwmUnregisterThumbnail: function(hThumbnailId: HTHUMBNAIL): HRESULT; stdcall;
  312. DwmUpdateThumbnailProperties: function(hThumbnailId: HTHUMBNAIL; ptnProperties: PDWM_THUMBNAIL_PROPERTIES): HRESULT; stdcall;
  313. // if(_WIN32_WINNT >= 0x0601)
  314. const
  315. DWM_SIT_DISPLAYFRAME = $00000001; // Display a window frame around the provided bitmap
  316. var
  317. DwmSetIconicThumbnail: function(hwnd: HWND; hbmp: HBITMAP; dwSITFlags: DWORD): HRESULT; stdcall;
  318. DwmSetIconicLivePreviewBitmap: function(hwnd: HWND; hbmp: HBITMAP; var ptClient: PPOINT; dwSITFlags: DWORD): HRESULT; stdcall;
  319. DwmInvalidateIconicBitmaps: function(hwnd: HWND): HRESULT; stdcall;
  320. // endif /* _WIN32_WINNT >= 0x0601 */
  321. var
  322. DwmAttachMilContent: function(hwnd: HWND): HRESULT; stdcall;
  323. DwmDetachMilContent: function(hwnd: HWND): HRESULT; stdcall;
  324. DwmFlush: function(): HRESULT; stdcall;
  325. type
  326. _MilMatrix3x2D = record
  327. S_11: DOUBLE;
  328. S_12: DOUBLE;
  329. S_21: DOUBLE;
  330. S_22: DOUBLE;
  331. DX: DOUBLE;
  332. DY: DOUBLE;
  333. end;
  334. MilMatrix3x2D = _MilMatrix3x2D;
  335. TMilMatrix3x2D = MilMatrix3x2D;
  336. var
  337. DwmGetGraphicsStreamTransformHint: function(uIndex: UINT; out pTransform: MilMatrix3x2D): HRESULT; stdcall;
  338. DwmGetGraphicsStreamClient: function(uIndex: UINT; out pClientUuid: TGUID): HRESULT; stdcall;
  339. DwmGetTransportAttributes: function(out pfIsRemoting: BOOL; out pfIsConnected: BOOL; out pDwGeneration: DWORD): HRESULT; stdcall;
  340. implementation
  341. const
  342. dwmlib = 'dwmapi.dll';
  343. var
  344. DwmLibrary: THandle;
  345. ReferenceCount: Integer; // We have to keep track of several load/unload calls.
  346. procedure FreeDwmLibrary;
  347. begin
  348. if ReferenceCount > 0 then
  349. Dec(ReferenceCount);
  350. if (DwmLibrary <> 0) and (ReferenceCount = 0) then
  351. begin
  352. FreeLibrary(DwmLibrary);
  353. DwmLibrary := 0;
  354. DwmDefWindowProc := nil;
  355. DwmEnableBlurBehindWindow := nil;
  356. DwmEnableComposition := nil;
  357. DwmEnableMMCSS := nil;
  358. DwmExtendFrameIntoClientArea := nil;
  359. DwmGetColorizationColor := nil;
  360. DwmGetCompositionTimingInfo := nil;
  361. DwmGetWindowAttribute := nil;
  362. DwmIsCompositionEnabled := nil;
  363. DwmModifyPreviousDxFrameDuration := nil;
  364. DwmQueryThumbnailSourceSize := nil;
  365. DwmRegisterThumbnail := nil;
  366. DwmSetDxFrameDuration := nil;
  367. DwmSetPresentParameters := nil;
  368. DwmSetWindowAttribute := nil;
  369. DwmUnregisterThumbnail := nil;
  370. DwmUpdateThumbnailProperties := nil;
  371. DwmAttachMilContent := nil;
  372. DwmDetachMilContent := nil;
  373. DwmFlush := nil;
  374. DwmGetGraphicsStreamTransformHint := nil;
  375. DwmGetGraphicsStreamClient := nil;
  376. DwmGetTransportAttributes := nil;
  377. DwmSetIconicThumbnail := nil;
  378. DwmSetIconicLivePreviewBitmap := nil;
  379. DwmInvalidateIconicBitmaps := nil;
  380. end;
  381. end;
  382. //----------------------------------------------------------------------------------------------------------------------
  383. function InitDwmLibrary: Boolean;
  384. begin
  385. Inc(ReferenceCount);
  386. if DwmLibrary = 0 then
  387. begin
  388. DwmLibrary := LoadLibrary(dwmlib);
  389. if DwmLibrary > 0 then
  390. begin
  391. // windows vista
  392. Pointer(DwmDefWindowProc) := GetProcAddress(DwmLibrary, 'DwmDefWindowProc');
  393. Pointer(DwmEnableBlurBehindWindow) := GetProcAddress(DwmLibrary, 'DwmEnableBlurBehindWindow');
  394. Pointer(DwmEnableComposition) := GetProcAddress(DwmLibrary, 'DwmEnableComposition');
  395. Pointer(DwmEnableMMCSS) := GetProcAddress(DwmLibrary, 'DwmEnableMMCSS');
  396. Pointer(DwmExtendFrameIntoClientArea) := GetProcAddress(DwmLibrary, 'DwmExtendFrameIntoClientArea');
  397. Pointer(DwmGetColorizationColor) := GetProcAddress(DwmLibrary, 'DwmGetColorizationColor');
  398. Pointer(DwmGetCompositionTimingInfo) := GetProcAddress(DwmLibrary, 'DwmGetCompositionTimingInfo');
  399. Pointer(DwmGetWindowAttribute) := GetProcAddress(DwmLibrary, 'DwmGetWindowAttribute');
  400. Pointer(DwmIsCompositionEnabled) := GetProcAddress(DwmLibrary, 'DwmIsCompositionEnabled');
  401. Pointer(DwmModifyPreviousDxFrameDuration) := GetProcAddress(DwmLibrary, 'DwmModifyPreviousDxFrameDuration');
  402. Pointer(DwmQueryThumbnailSourceSize) := GetProcAddress(DwmLibrary, 'DwmQueryThumbnailSourceSize');
  403. Pointer(DwmRegisterThumbnail) := GetProcAddress(DwmLibrary, 'DwmRegisterThumbnail');
  404. Pointer(DwmSetDxFrameDuration) := GetProcAddress(DwmLibrary, 'DwmSetDxFrameDuration');
  405. Pointer(DwmSetPresentParameters) := GetProcAddress(DwmLibrary, 'DwmSetPresentParameters');
  406. Pointer(DwmSetWindowAttribute) := GetProcAddress(DwmLibrary, 'DwmSetWindowAttribute');
  407. Pointer(DwmUnregisterThumbnail) := GetProcAddress(DwmLibrary, 'DwmUnregisterThumbnail');
  408. Pointer(DwmUpdateThumbnailProperties) := GetProcAddress(DwmLibrary, 'DwmUpdateThumbnailProperties');
  409. Pointer(DwmAttachMilContent) := GetProcAddress(DwmLibrary, 'DwmAttachMilContent');
  410. Pointer(DwmDetachMilContent) := GetProcAddress(DwmLibrary, 'DwmDetachMilContent');
  411. Pointer(DwmFlush) := GetProcAddress(DwmLibrary, 'DwmFlush');
  412. Pointer(DwmGetGraphicsStreamTransformHint) := GetProcAddress(DwmLibrary, 'DwmGetGraphicsStreamTransformHint');
  413. Pointer(DwmGetGraphicsStreamClient) := GetProcAddress(DwmLibrary, 'DwmGetGraphicsStreamClient');
  414. Pointer(DwmGetTransportAttributes) := GetProcAddress(DwmLibrary, 'DwmGetTransportAttributes');
  415. // windows 7
  416. Pointer(DwmSetIconicThumbnail) := GetProcAddress(DwmLibrary, 'DwmSetIconicThumbnail');
  417. Pointer(DwmSetIconicLivePreviewBitmap) := GetProcAddress(DwmLibrary, 'DwmSetIconicLivePreviewBitmap');
  418. Pointer(DwmInvalidateIconicBitmaps) := GetProcAddress(DwmLibrary, 'DwmInvalidateIconicBitmaps');
  419. end;
  420. end;
  421. Result := DwmLibrary > 0;
  422. end;
  423. function DwmCompositionEnabled: Boolean;
  424. var
  425. B: BOOL;
  426. begin
  427. Result := DwmLibrary > 0;
  428. if Result then
  429. Result := (DwmIsCompositionEnabled(B) = S_OK) and B;
  430. end;
  431. initialization
  432. ReferenceCount := 0;
  433. finalization
  434. while ReferenceCount > 0 do
  435. FreeDwmLibrary;
  436. end.