Crate lnk

Crate lnk 

Source
Expand description

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§

CurrentOffset
implements BinRead by reading the current cursor position and storing it as u32
FileAttributeFlags
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.
FileTime
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).
FixedSizeString
represents a string that is stored in a buffer of a fixed size
Guid
wraps a UUID
HotkeyFlags
The HotkeyFlags structure specifies input generated by a combination of keyboard keys being pressed.
HotkeyModifiers
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.
LinkFlags
The LinkFlags structure defines bits that specify which shell linkstructures are present in the file format after the ShellLinkHeaderstructure (section 2.1).
NullTerminatedString
represents a string of unknown length which is NULL-terminated
ShellLink
A shell link
ShellLinkHeader
A ShellLinkHeader structure (section 2.1), which contains identification information, timestamps, and flags that specify the presence of optional structures.
StringData
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.
HotkeyKey
An 8-bit unsigned integer that specifies a virtual key code that corresponds to a key on the keyboard.
ShowCommand
The expected window state of an application launched by the link.
StringEncoding
enum to select which string encoding should be used

Functions§

parse_sized_string
reads a sized string from reader and converts it into a String

Type Aliases§

Encoding
this type wraps encoding_rs::Encoding so that depending crates do not need to to depend on encoding_rs