Expand description
§Shell Link parser and writer for Rust.
Works on any OS - although only really useful in Windows, this library can parse and write .lnk files, a shell link, that can be understood by Windows.
To get started, see the ShellLink struct.
The full specification of these files can be found at Microsoft’s Website.
§Read Example
A simple example appears as follows:
use lnk::ShellLink;
use lnk::encoding::WINDOWS_1252;
// ...
let shortcut = lnk::ShellLink::open("tests/data/test.lnk", WINDOWS_1252).unwrap();
println!("{:#?}", shortcut);§Write Example
A simple example appears as follows:
ⓘ
use lnk::ShellLink;
// ...
ShellLink::new_simple(std::path::Path::new(r"C:\Windows\System32\notepad.exe"));IMPORTANT!: Writing capability is currently in a very early stage and probably won’t work!
Re-exports§
pub use linktarget::LinkTargetIdList;pub use linkinfo::LinkInfo;pub use extradata::ExtraData;
Modules§
- encoding
- this module reexports all statics from
encoding_rs - extradata
- Structures from the ExtraData section of the Shell Link.
- linkinfo
- The LinkInfo structure specifies information necessary to resolve a linktarget if it is not found in its original location. This includes information about the volume that the target was stored on, the mapped drive letter, and a Universal Naming Convention (UNC)form of the path if one existed when the linkwas created. For more details about UNC paths, see [MS-DFSNM] section 2.2.1.4
- linktarget
- The LinkTargetIDList structure specifies the target of the link. The presence of this optional structure is specified by the HasLinkTargetIDList bit (LinkFlagssection 2.1.1) in the ShellLinkHeader(section2.1).
Structs§
- Current
Offset - implements
BinReadby reading the current cursor position and storing it asu32 - File
Attribute Flags - The FileAttributesFlags structure defines bits that specify the file attributes of the link target, if the target is a file system item. File attributes can be used if the link target is not available, or if accessing the target would be inefficient. It is possible for the target items attributes to be out of sync with this value.
- File
Time - The FILETIME structure is a 64-bit value that represents the number of 100-nanosecond intervals that have elapsed since January 1, 1601, Coordinated Universal Time (UTC).
- Fixed
Size String - represents a string that is stored in a buffer of a fixed size
- Guid
- wraps a UUID
- Hotkey
Flags - The HotkeyFlags structure specifies input generated by a combination of keyboard keys being pressed.
- Hotkey
Modifiers - An 8-bit unsigned integer that specifies bits that correspond to modifier keys on the keyboard
- IdList
- The stored IDList structure specifies the format of a persisted item ID list.
- ItemID
- The stored IDList structure specifies the format of a persisted item ID list.
- Link
Flags - The LinkFlags structure defines bits that specify which shell linkstructures are present in the file format after the ShellLinkHeaderstructure (section 2.1).
- Null
Terminated String - represents a string of unknown length which is NULL-terminated
- Shell
Link - A shell link
- Shell
Link Header - A ShellLinkHeader structure (section 2.1), which contains identification information, timestamps, and flags that specify the presence of optional structures.
- String
Data - StringData refers to a set of structures that convey user interface and path identification information. The presence of these optional structures is controlled by LinkFlags (section 2.1.1) in the ShellLinkHeader (section 2.1).
Enums§
- Error
- The error type for shell link parsing errors.
- Hotkey
Key - An 8-bit unsigned integer that specifies a virtual key code that corresponds to a key on the keyboard.
- Show
Command - The expected window state of an application launched by the link.
- String
Encoding - enum to select which string encoding should be used
Functions§
- parse_
sized_ string - reads a sized string from
readerand converts it into aString
Type Aliases§
- Encoding
- this type wraps
encoding_rs::Encodingso that depending crates do not need to to depend onencoding_rs