| Crates.io | win-ctx |
| lib.rs | win-ctx |
| version | 1.4.1 |
| created_at | 2025-03-25 07:06:41.096454+00 |
| updated_at | 2025-06-10 23:21:30.581159+00 |
| description | Library for managing Windows context menu entries |
| homepage | |
| repository | https://github.com/acdvs/winctx-rs |
| max_upload_size | |
| id | 1604897 |
| size | 45,518 |
A Rust library for managing Windows context menu entries.
cargo add win-ctx
The following code creates a top-level context menu entry that appears on right-clicked folders and opens the target folder in the terminal.
use win_ctx::*;
CtxEntry::new_with_options(
"Open in terminal",
&ActivationType::Folder,
&EntryOptions {
command: Some("cmd /s /k pushd \"%V\""),
icon: Some("C:\\Windows\\System32\\cmd.exe"),
position: None,
extended: false,
}
)?;
The following code creates a context menu entry with child entries that each open the target folder in the selected program.
To reduce line count, the more basic non-options functions can be used, and individual values are then set on the resulting entries.
use win_ctx::{CtxEntry, ActivationType};
let mut parent = CtxEntry::new("Open directory in", &ActivationType::Background)?;
let mut child_1 = parent.new_child("Terminal")?;
child_1.set_command(Some("cmd /s /k pushd \"%V\""))?;
child_1.set_icon(Some("C:\\Windows\\System32\\cmd.exe"))?;
let mut child_2 = parent.new_child("Powershell")?;
child_2.set_command(Some("powershell -noexit -command Set-Location -literalPath '%V'"))?;
child_2.set_icon(Some("C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"))?;
It's possible that an entry's underlying registry key goes out of sync,
so most CtxEntry functions verify this and return a std::io::Result.
Errors will have an ErrorKind of either:
PermissionDenied for insufficient privileges,InvalidValue for invalid entry renames, orNotFound for operations on missing keys and values.