wininskit 0.1.1

Thin checked wrappers over the Win32 an installer needs: elevation, ACLs, services, the Restart Manager, the registry and shortcuts.
docs.rs failed to build wininskit-0.1.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

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.

Area Functions
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, 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
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 asks the process to close through WM_CLOSE and waits before terminating it. 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.