windows_snapshot/operating_system/desktop.rs
1//! The Desktop subcategory groups classes that represent objects that define a specific desktop configuration.
2//!
3//! | Class | Description |
4//! |-------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------|
5//! | [**Win32\_Desktop**](win32-desktop) | Instance class<br/> Represents the common characteristics of a user's desktop.<br/> |
6//! | [**Win32\_Environment**](win32-environment) | Instance class<br/> Represents an environment or system environment setting on a computer system running Windows.<br/> |
7//! | [**Win32\_TimeZone**](win32-timezone) | Instance class<br/> Represents the time zone information for a computer system running Windows.<br/> |
8//! | [**Win32\_UserDesktop**](win32-userdesktop) | Association class<br/> Relates a user account and the desktop settings that are specific to it.<br/> |
9
10use crate::operating_system::users::Win32_UserAccount;
11use crate::update;
12use serde::{Deserialize, Serialize};
13use std::time::SystemTime;
14use wmi::{COMLibrary, WMIConnection, WMIDateTime};
15
16/// Represents the state of Windows user's desktops
17#[derive(Deserialize, Serialize, Debug, Clone)]
18pub struct Desktops {
19 /// Sequence of windows Desktop states
20 pub desktops: Vec<Win32_Desktop>,
21 /// When was the record last updated
22 pub last_updated: SystemTime,
23}
24
25update!(Desktops, desktops);
26
27/// Represents the state of Windows Environment
28#[derive(Deserialize, Serialize, Debug, Clone)]
29pub struct Environments {
30 /// Sequence of windows Environment states
31 pub environments: Vec<Win32_Environment>,
32 /// When was the record last updated
33 pub last_updated: SystemTime,
34}
35
36update!(Environments, environments);
37
38/// Represents the state of Windows TimeZone
39#[derive(Deserialize, Serialize, Debug, Clone)]
40pub struct TimeZones {
41 /// Sequence of windows TimeZone states
42 pub timezones: Vec<Win32_TimeZone>,
43 /// When was the record last updated
44 pub last_updated: SystemTime,
45}
46
47update!(TimeZones, timezones);
48
49/// Represents the state of Windows User Desktops
50#[derive(Deserialize, Serialize, Debug, Clone)]
51pub struct UserDesktops {
52 /// user account and desktop settings that are specific to it
53 pub user_desktops: Vec<Win32_UserDesktop>,
54 /// When was the record last updated
55 pub last_updated: SystemTime,
56}
57
58update!(UserDesktops, user_desktops);
59
60/// The `Win32_Desktop` WMI class represents the common characteristics of a user's desktop. The
61/// properties of this class can be modified by the user to customize the desktop.
62///
63/// <https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-desktop>
64#[derive(Default, Deserialize, Serialize, Debug, Clone)]
65#[allow(non_snake_case)]
66#[allow(non_camel_case_types)]
67pub struct Win32_Desktop {
68 /// Short textual description of the current object.
69 pub Caption: Option<String>,
70 /// Textual description of the current object.
71 pub Description: Option<String>,
72 /// Identifier by which the current object is known.
73 pub SettingID: Option<String>,
74 /// Width of the borders around all windows with adjustable borders.
75 ///
76 /// Example: 3
77 pub BorderWidth: Option<u32>,
78 /// Fast task switching is turned on. Fast task switching allows the user to switch between
79 /// windows using the ALT+TAB keyboard combination.
80 pub CoolSwitch: Option<bool>,
81 /// Length of time between successive cursor blinks.
82 ///
83 /// Example: 530
84 pub CursorBlinkRate: Option<u32>,
85 /// Contents of a window are shown when a user moves the window.
86 pub DragFullWindows: Option<bool>,
87 /// Spacing of the grid that windows are bound to on the desktop. This makes organizing windows
88 /// easier. The spacing is usually fine enough that the user does not notice it.
89 ///
90 /// Example: 1
91 pub GridGranularity: Option<u32>,
92 /// Spacing between icons.
93 ///
94 /// Example: 75
95 pub IconSpacing: Option<u32>,
96 /// Font used for the names of the icons.
97 ///
98 /// Example: "MS San Serif"
99 pub IconTitleFaceName: Option<String>,
100 /// Icon font size.
101 ///
102 /// Example: 9
103 pub IconTitleSize: Option<u32>,
104 /// Icon's title text wraps to the next line.
105 pub IconTitleWrap: Option<bool>,
106 /// Name that identifies the current desktop profile.
107 ///
108 /// Example: "MainProf"
109 pub Name: Option<String>,
110 /// Name of the pattern used as the background for the desktop.
111 pub Pattern: Option<String>,
112 /// Screen saver is active.
113 pub ScreenSaverActive: Option<bool>,
114 /// Name of the current screen saver executable file.
115 ///
116 /// Example: "LOGON.SCR"
117 pub ScreenSaverExecutable: Option<String>,
118 /// Password is enabled for the screen saver.
119 pub ScreenSaverSecure: Option<bool>,
120 /// Amount of time that passes before the screen saver starts.
121 pub ScreenSaverTimeout: Option<u32>,
122 /// File name for the wallpaper design on the background of the desktop.
123 ///
124 /// Example: "WINNT.BMP"
125 pub Wallpaper: Option<String>,
126 /// Wallpaper is stretched to fill the entire screen. Microsoft Plus! must be installed before
127 /// this option is available. If FALSE, the wallpaper retains its original dimensions on the
128 /// desktop background.
129 pub WallpaperStretched: Option<bool>,
130 /// Wallpaper is tiled or centered.
131 pub WallpaperTiled: Option<bool>,
132}
133
134/// The `Win32_Environment` WMI class represents an environment or system environment setting on a
135/// Windows computer system. Querying this class returns environment variables found in:
136///
137/// `HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Sessionmanager\Environment`
138///
139/// and
140///
141/// `HKEY_USERS\<user>\Environment`
142///
143/// <https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-environment>
144#[derive(Default, Deserialize, Serialize, Debug, Clone)]
145#[allow(non_snake_case)]
146#[allow(non_camel_case_types)]
147pub struct Win32_Environment {
148 /// A short textual description of the object.
149 pub Caption: Option<String>,
150 /// A textual description of the object.
151 pub Description: Option<String>,
152 /// Indicates when the object was installed. Lack of a value does not indicate that the object
153 /// is not installed.
154 pub InstallDate: Option<WMIDateTime>,
155 /// String that indicates the current status of the object.
156 /// Operational and non-operational status can be defined.
157 /// Operational status can include "OK", "Degraded", and "Pred Fail".
158 /// "Pred Fail" indicates that an element is functioning properly,
159 /// but is predicting a failure (for example, a SMART-enabled hard disk drive).
160 ///
161 /// Non-operational status can include "Error", "Starting", "Stopping", and "Service".
162 /// "Service" can apply during disk mirror-re-silvering,
163 /// reloading a user permissions list, or other administrative work.
164 /// Not all such work is online,
165 /// but the managed element is neither "OK" nor in one of the other states.
166 ///
167 /// Values include the following:
168 ///
169 /// - OK ("OK")
170 /// - Error ("Error")
171 /// - Degraded ("Degraded")
172 /// - Unknown ("Unknown")
173 /// - Pred Fail ("Pred Fail")
174 /// - Starting ("Starting")
175 /// - Stopping ("Stopping")
176 /// - Service ("Service")
177 /// - Stressed ("Stressed")
178 /// - NonRecover ("NonRecover")
179 /// - No Contact ("No Contact")
180 /// - Lost Comm ("Lost Comm")
181 pub Status: Option<String>,
182 /// Character string that specifies the name of a Windows-based environment variable.
183 /// By specifying the name of a variable that does not yet exist,
184 /// an application creates a new environment variable.
185 ///
186 /// Example: "Path"
187 pub Name: Option<String>,
188 /// Indicates whether the variable is a system variable.
189 /// A system variable is set by the operating system,
190 /// and is independent from user environment settings.
191 pub SystemVariable: Option<bool>,
192 /// Name of the owner of the environment setting.
193 /// It is set to <SYSTEM> for settings that are specific to the Windows-based system
194 /// (as opposed to a specific user) and <DEFAULT> for default user settings.
195 ///
196 /// Example: "JSmith"
197 pub UserName: Option<String>,
198 /// Placeholder variable of a Windows-based environment variable.
199 /// Information like the file system directory can change from computer to computer.
200 /// The operating system substitutes placeholders for these.
201 ///
202 /// Example: "%SystemRoot%"
203 pub VariableValue: Option<String>,
204}
205
206/// The `Win32_TimeZone`
207/// WMI class represents the time zone information for a computer system running Windows,
208/// which includes the changes required for transitioning to daylight saving time transition.
209///
210/// <https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-timezone>
211#[derive(Default, Deserialize, Serialize, Debug, Clone)]
212#[allow(non_snake_case)]
213#[allow(non_camel_case_types)]
214pub struct Win32_TimeZone {
215 /// Short textual description of the current object.
216 pub Caption: Option<String>,
217 /// Textual description of the current object.
218 pub Description: Option<String>,
219 /// Identifier by which the current object is known.
220 pub SettingID: Option<String>,
221 /// Current bias for local time translation.
222 /// The bias is the difference between Coordinated Universal Time (UTC) and local time.
223 /// All translations between UTC and local time are based on the following formula:
224 /// UTC = local time - bias.
225 /// This property is required.
226 pub Bias: Option<i32>,
227 /// Bias value to be used during local time translations that occur during daylight saving time.
228 /// This property is ignored if a value for the DaylightDay property is not supplied.
229 /// The value of this property is added to the Bias property
230 /// to form the bias used during daylight time.
231 /// In most time zones, the value of this property is -60.
232 pub DaylightBias: Option<i32>,
233 /// DaylightDayOfWeek of the DaylightMonth when the transition from standard time to daylight
234 /// saving time occurs on this operating system.
235 ///
236 /// Example: If the transition day (DaylightDayOfWeek) occurs on a Sunday, then the value "1"
237 /// indicates the first Sunday of the DaylightMonth,
238 /// "2" indicates the second Sunday, and so on.
239 /// The value "5" indicates the last DaylightDayOfWeek in the month.
240 pub DaylightDay: Option<u32>,
241 /// Day of the week when the transition from standard time to daylight saving time occurs on an
242 /// operating system.
243 ///
244 /// - Sunday (0)
245 /// - Monday (1)
246 /// - Tuesday (2)
247 /// - Wednesday (3)
248 /// - Thursday (4)
249 /// - Friday (5)
250 /// - Saturday (6)
251 ///
252 /// Example: 1
253 pub DaylightDayOfWeek: Option<u8>,
254 /// Hour of the day when the transition from standard time to daylight saving time occurs on an
255 /// operating system.
256 ///
257 /// Example: 2
258 pub DaylightHour: Option<u32>,
259 /// Millisecond of the DaylightSecond when the transition from standard time to daylight saving
260 /// time occurs on an operating system.
261 pub DaylightMillisecond: Option<u32>,
262 /// Minute of the DaylightHour when the transition from standard time to daylight saving time
263 /// occurs on an operating system.
264 ///
265 /// Example: 59
266 pub DaylightMinute: Option<u32>,
267 /// Month when the transition from standard time to daylight saving time occurs on an
268 /// operating system.
269 ///
270 /// - January (1)
271 /// - February (2)
272 /// - March (3)
273 /// - April (4)
274 /// - May (5)
275 /// - June (6)
276 /// - July (7)
277 /// - August (8)
278 /// - September (9)
279 /// - October (10)
280 /// - November (11)
281 /// - December (12)
282 pub DaylightMonth: Option<u32>,
283 /// Time zone being represented when daylight saving time is in effect.
284 ///
285 /// Example: "EDT" (Eastern Daylight Time)
286 pub DaylightName: Option<String>,
287 /// Second of the DaylightMinute when the transition from standard time to daylight saving time
288 /// occurs on an operating system.
289 ///
290 /// Example: 59
291 pub DaylightSecond: Option<u32>,
292 /// Year when daylight saving time is in effect. This property is not required.
293 ///
294 /// Example: 1997
295 pub DaylightYear: Option<u32>,
296 /// Bias value to use when daylight saving time is not in effect. This property is ignored if a
297 /// value for StandardDay is not supplied. The value of this property is added to the Bias
298 /// property to form the bias during standard time.
299 ///
300 /// Example: 0
301 pub StandardBias: Option<u32>,
302 /// StandardDayOfWeek of the StandardMonth when the transition from daylight saving time to
303 /// standard time occurs on an operating system.
304 ///
305 /// If the transition day (StandardDayOfWeek) occurs on a Sunday,
306 /// then the value "1" indicates the first Sunday of the StandardMonth,
307 /// "2" indicates the second Sunday, and so on.
308 /// The value "5" indicates the last StandardDayOfWeek in the month.
309 pub StandardDay: Option<u32>,
310 /// Day of the week when the transition from daylight saving time to standard time occurs on an
311 /// operating system.
312 ///
313 /// - Sunday (0)
314 /// - Monday (1)
315 /// - Tuesday (2)
316 /// - Wednesday (3)
317 /// - Thursday (4)
318 /// - Friday (5)
319 /// - Saturday (6)
320 pub StandardDayOfWeek: Option<u8>,
321 /// Hour of the day when the transition from daylight saving time to standard time occurs on an
322 /// operating system.
323 ///
324 /// Example: 11
325 pub StandardHour: Option<u32>,
326 /// Millisecond of the StandardSecond when the transition from daylight saving time to standard
327 /// time occurs on an operating system.
328 pub StandardMillisecond: Option<u32>,
329 /// Minute of the StandardDay when the transition from daylight saving time to standard time
330 /// occurs on an operating system.
331 ///
332 /// Example: 59
333 pub StandardMinute: Option<u32>,
334 /// Month when the transition from daylight saving time to standard time occurs on an
335 /// operating system.
336 ///
337 /// - January (1)
338 /// - February (2)
339 /// - March (3)
340 /// - April (4)
341 /// - May (5)
342 /// - June (6)
343 /// - July (7)
344 /// - August (8)
345 /// - September (9)
346 /// - October (10)
347 /// - November (11)
348 /// - December (12)
349 pub StandardMonth: Option<u32>,
350 /// Name of the time zone being represented when standard time is in effect.
351 ///
352 /// Example: "EST" (Eastern Standard Time)
353 pub StandardName: Option<String>,
354 /// Second of the StandardMinute when the transition from daylight saving time to standard time
355 /// occurs on an operating system.
356 ///
357 /// Example: 59
358 pub StandardSecond: Option<u32>,
359 /// Year when standard time is in effect. This property is not required.
360 ///
361 /// Example: 1997
362 pub StandardYear: Option<u32>,
363}
364
365/// The `Win32_UserDesktop` association WMI class relates a user account and desktop settings that
366/// are specific to it.
367///
368/// <https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-userdesktop>
369#[derive(Default, Deserialize, Serialize, Debug, Clone)]
370#[allow(non_snake_case)]
371#[allow(non_camel_case_types)]
372pub struct Win32_UserDesktop {
373 /// Reference to the instance representing the user account whose desktop can be customized by
374 /// the Settings property of this class.
375 pub Element: Option<Win32_UserAccount>,
376 /// Reference to the instance representing the desktop settings that serve to customize a
377 /// specific user account desktop.
378 pub Setting: Option<Win32_Desktop>,
379}