| 93 | } |
| 94 | |
| 95 | pub fn create_lnk(lnk: &str, target: &str, desc: &str, args: &str) -> Result<()> { |
| 96 | pcwstr! { |
| 97 | let lnk; |
| 98 | let target; |
| 99 | let desc; |
| 100 | let args; |
| 101 | } |
| 102 | unsafe { |
| 103 | CoInitialize(None)?; |
| 104 | let shell_link: IShellLinkW = CoCreateInstance(&ShellLink, None, CLSCTX_INPROC_SERVER)?; |
| 105 | shell_link.SetPath(target)?; |
| 106 | shell_link.SetDescription(desc)?; |
| 107 | shell_link.SetArguments(args)?; |
| 108 | let persist_file: IPersistFile = Interface::cast(&shell_link)?; |
| 109 | persist_file.Save(lnk, true)?; |
| 110 | CoUninitialize(); |
| 111 | } |
| 112 | Ok(()) |
| 113 | } |
| 114 | |
| 115 | pub fn free_console() -> bool { |
| 116 | // https://github.com/rust-lang/rust/issues/100884 |