# wininskit
The Win32 an installer needs, as thin checked wrappers over the calls that do
the job rather than shell-outs to `sc`, `icacls` or `taskkill`. Windows only.
Every call returns `wininskit::Result`,
whose error carries the Win32 code and what was being attempted.
| Elevation | `is_elevated()` |
| Files | `grant_users_full_access(path)`, `delete_after_restart(path)` |
| Processes | `running_from(directory)`, `close(id, wait)`, `locking_processes(files)` (Restart Manager) |
| Services | `service_state(name)`, `stop_service(name, timeout)`, `start_service(name)` |
| Registry | `read_string`, `write_string`, `write_dword`, `subkeys`, `delete_tree`, under `Root::LocalMachine` or `Root::CurrentUser` |
| Shortcuts | `create_shortcut(...)`, a `.lnk` through `IShellLink` |
| Windows | `round_corners()`, the DWM corners and shadow for a window that draws its own frame |
```rust
use std::time::Duration;
if !wininskit::is_elevated() {
return Err("run as administrator".into());
}
wininskit::stop_service("MyLicensingService", Duration::from_secs(30))?;
for process in wininskit::locking_processes(&[std::path::Path::new(r"C:\Program Files\My\my.dll")])? {
wininskit::close(process.id, Duration::from_secs(5))?;
}
wininskit::write_string(
wininskit::Root::LocalMachine,
r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\My",
"DisplayName",
"My",
)?;
```
`close` terminates the process outright and waits for it to be gone; it does
not ask the program to close first, so nothing unsaved in it is kept, and a
process that has already ended counts as closed. `delete_after_restart`
schedules a file Windows will not let go of for deletion at the next boot.
Built on `windows-sys`; the shortcut is the one place that needs COM and takes
the `windows` crate for it.
## License
MIT.