ShellLink

Struct ShellLink 

Source
pub struct ShellLink { /* private fields */ }
Expand description

A shell link

Implementations§

Source

pub fn header(&self) -> &ShellLinkHeader

returns the ShellLinkHeader structure

Source

pub fn linktarget_id_list(&self) -> &Option<LinkTargetIdList>

returns the LinkTargetIdList structure

returns the LinkInfo structure

Source

pub fn string_data(&self) -> &StringData

returns the StringData structure

Source

pub fn extra_data(&self) -> &ExtraData

returns the ExtraData structure

Source

pub fn header_mut(&mut self) -> &mut ShellLinkHeader

returns the ShellLinkHeader structure

Source

pub fn linktarget_id_list_mut(&mut self) -> &mut Option<LinkTargetIdList>

returns the LinkTargetIdList structure

returns the LinkInfo structure

Source

pub fn string_data_mut(&mut self) -> &mut StringData

returns the StringData structure

Source

pub fn extra_data_mut(&mut self) -> &mut ExtraData

returns the ExtraData structure

Source

pub fn new_simple<P: AsRef<Path>>(to: P) -> Result<Self>

Create a new ShellLink pointing to a location, with otherwise default settings.

Source

pub fn with_encoding(self, encoding: &StringEncoding) -> Self

change the encoding for this link

Source

pub fn open<P: AsRef<Path>>(path: P, encoding: Encoding) -> Result<Self, Error>

Open and parse a shell link

All string which are stored in the lnk file are encoded with either Unicode (UTF-16LE) of any of the Windows code pages. Which of both is being used is specified by the LinkFlags::IS_UNICODE flag. Microsoft documents this as follows:

If this bit is set, the StringData section contains Unicode-encoded strings; otherwise, it contains strings that are encoded using the system default code page.

(https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-shllink/ae350202-3ba9-4790-9e9e-98935f4ee5af)

The system default code page is stored in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage\ACP

Because we do not know what the system default code page was, you must specify this using the encoding parameter (see below). If you you do not know the system default code page either, you’re lost. There is no way to correctly guess the used code page from the data in the lnk file.

  • path - path of the lnk file to be analyzed
  • encoding - character encoding to be used if the lnk file is not Unicode encoded

returns the full path of the link target. This information is constructed completely from the LINK_INFO structure. So, if the lnk file does not contain such a structure, the result of this method will be None

Source

pub fn set_name(&mut self, name: Option<String>)

Set the shell link’s name

Source

pub fn set_relative_path(&mut self, relative_path: Option<String>)

Set the shell link’s relative path

Source

pub fn set_working_dir(&mut self, working_dir: Option<String>)

Set the shell link’s working directory

Source

pub fn set_arguments(&mut self, arguments: Option<String>)

Set the shell link’s arguments

Source

pub fn set_icon_location(&mut self, icon_location: Option<String>)

Set the shell link’s icon location

Trait Implementations§

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

fn default() -> Self

Create a new ShellLink, left blank for manual configuration. For those who are not familar with the Shell Link specification, I suggest you look at the ShellLink::new_simple method.

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.