-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMaxlogic.GdiUtils.pas
More file actions
52 lines (41 loc) · 1.37 KB
/
Copy pathMaxlogic.GdiUtils.pas
File metadata and controls
52 lines (41 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
unit Maxlogic.GdiUtils;
interface
uses
Winapi.Windows;
/// <summary>
/// Retrieves the count of GUI resources (GDI or User objects)
/// currently used by the calling process.
/// </summary>
/// <param name="aResourceType">Specify GR_GDIOBJECTS or GR_USEROBJECTS.</param>
/// <returns>The number of handles, or 0 on failure.</returns>
function GetGuiResourceCount(aResourceType: DWORD): DWORD;
/// <summary>
/// Gets the current count of GDI objects (bitmaps, pens, brushes, fonts, DCs, regions)
/// used by this process.
/// </summary>
/// <returns>The number of GDI handles.</returns>
function GetGDIObjectCount: DWORD;
/// <summary>
/// Gets the current count of User objects (windows, menus, cursors, icons, etc.)
/// used by this process.
/// </summary>
/// <returns>The number of User handles.</returns>
function GetUserObjectCount: DWORD;
implementation
function GetGuiResourceCount(aResourceType: DWORD): DWORD;
var
lProcessHandle: THandle;
begin
lProcessHandle := GetCurrentProcess(); // Gets a pseudo-handle for the current process
Result := Winapi.Windows.GetGuiResources(lProcessHandle, aResourceType);
// No need to close the pseudo-handle returned by GetCurrentProcess
end;
function GetGDIObjectCount: DWORD;
begin
Result := GetGuiResourceCount(GR_GDIOBJECTS);
end;
function GetUserObjectCount: DWORD;
begin
Result := GetGuiResourceCount(GR_USEROBJECTS);
end;
end.