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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#![allow(non_camel_case_types, non_snake_case)]
use crate::decl::*;
use crate::macros::*;
use crate::ole::privs::*;
use crate::prelude::*;
use crate::taskschd::vts::*;
com_interface! { ITaskService: "2faba4c7-4da9-4013-9697-20cc3fd40f85";
/// [`ITaskService`](https://learn.microsoft.com/en-us/windows/win32/api/taskschd/nn-taskschd-itaskservice)
/// COM interface.
///
/// Automatically calls
/// [`Release`](https://learn.microsoft.com/en-us/windows/win32/api/unknwn/nf-unknwn-iunknown-release)
/// when the object goes out of scope.
///
/// # Examples
///
/// ```no_run
/// use winsafe::{self as w, prelude::*, co};
///
/// let obj = w::CoCreateInstance::<w::ITaskService>(
/// &co::CLSID::TaskScheduler,
/// None::<&w::IUnknown>,
/// co::CLSCTX::INPROC_SERVER,
/// )?;
/// # w::HrResult::Ok(())
/// ```
}
impl oleaut_IDispatch for ITaskService {}
impl taskschd_ITaskService for ITaskService {}
/// This trait is enabled with the `taskschd` feature, and provides methods for
/// [`ITaskService`](crate::ITaskService).
///
/// Prefer importing this trait through the prelude:
///
/// ```no_run
/// use winsafe::prelude::*;
/// ```
pub trait taskschd_ITaskService: oleaut_IDispatch {
/// [`ITaskService::Connect`](https://learn.microsoft.com/en-us/windows/win32/api/taskschd/nf-taskschd-itaskservice-connect)
/// method.
fn Connect(
&self,
server_name: Option<&str>,
user: Option<&str>,
domain: Option<&str>,
password: Option<&str>,
) -> HrResult<()> {
HrRet(unsafe {
(vt::<ITaskServiceVT>(self).Connect)(
self.ptr(),
Variant::from_opt_str(server_name).to_raw()?,
Variant::from_opt_str(user).to_raw()?,
Variant::from_opt_str(domain).to_raw()?,
Variant::from_opt_str(password).to_raw()?,
)
})
.to_hrresult()
}
/// [`ITaskService::get_Connected`](https://learn.microsoft.com/en-us/windows/win32/api/taskschd/nf-taskschd-itaskservice-get_connected)
/// method.
#[must_use]
fn get_Connected(&self) -> HrResult<bool> {
let mut connected = i16::default();
HrRet(unsafe { (vt::<ITaskServiceVT>(self).get_Connected)(self.ptr(), &mut connected) })
.to_hrresult()
.map(|_| connected != 0)
}
fn_com_bstr_get! { get_ConnectedDomain: ITaskServiceVT;
/// [`ITaskService::get_ConnectedDomain`](https://learn.microsoft.com/en-us/windows/win32/api/taskschd/nf-taskschd-itaskservice-get_connecteddomain)
/// method.
}
fn_com_bstr_get! { get_ConnectedUser: ITaskServiceVT;
/// [`ITaskService::get_ConnectedUser`](https://learn.microsoft.com/en-us/windows/win32/api/taskschd/nf-taskschd-itaskservice-get_connecteduser)
/// method.
}
/// [`ITaskService::get_HighestVersion`](https://learn.microsoft.com/en-us/windows/win32/api/taskschd/nf-taskschd-itaskservice-get_highestversion)
/// method.
#[must_use]
fn get_HighestVersion(&self) -> HrResult<u32> {
let mut ver = 0u32;
HrRet(unsafe { (vt::<ITaskServiceVT>(self).get_HighestVersion)(self.ptr(), &mut ver) })
.to_hrresult()
.map(|_| ver)
}
fn_com_bstr_get! { get_TargetServer: ITaskServiceVT;
/// [`ITaskService::get_TargetServer`](https://learn.microsoft.com/en-us/windows/win32/api/taskschd/nf-taskschd-itaskservice-get_targetserver)
/// method.
}
/// [`ITaskService::GetFolder`](https://learn.microsoft.com/en-us/windows/win32/api/taskschd/nf-taskschd-itaskservice-getfolder)
/// method.
#[must_use]
fn GetFolder(&self, path: &str) -> HrResult<ITaskFolder> {
let mut queried = unsafe { ITaskFolder::null() };
HrRet(unsafe {
(vt::<ITaskServiceVT>(self).GetFolder)(
self.ptr(),
BSTR::SysAllocString(path)?.as_ptr(),
queried.as_mut(),
)
})
.to_hrresult()
.map(|_| queried)
}
/// [`ITaskService::NewTask`](https://learn.microsoft.com/en-us/windows/win32/api/taskschd/nf-taskschd-itaskservice-newtask)
/// method.
#[must_use]
fn NewTask(&self) -> HrResult<ITaskDefinition> {
let mut queried = unsafe { ITaskDefinition::null() };
HrRet(unsafe { (vt::<ITaskServiceVT>(self).NewTask)(self.ptr(), 0, queried.as_mut()) })
.to_hrresult()
.map(|_| queried)
}
}