shortcut

package module
v0.0.0-...-8b0c89b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2022 License: MIT Imports: 1 Imported by: 1

README

go-windows-shortcut

GoDoc

// +build run

package main

import (
    "fmt"
    "os"

    "github.com/go-ole/go-ole"
    "github.com/nyaosorg/go-windows-shortcut"
)

func main1() error {
    ole.CoInitialize(0)
    defer ole.CoUninitialize()

    if len(os.Args) < 3 {
        return fmt.Errorf("Usage: go run example.go SRC DST")
    }
    src1 := os.Args[1]
    dst1 := os.Args[2]

    fmt.Printf("make shortcut: %s --> %s\n", src1, dst1)
    if err := shortcut.Make(src1, dst1, ""); err != nil {
        return err
    }

    src2, _, err := shortcut.Read(dst1)
    if err != nil {
        return err
    }
    fmt.Printf("read shortcut: %s <-- %s\n", dst1, src2)
    return nil
}

func main() {
    if err := main1(); err != nil {
        fmt.Fprintln(os.Stderr, err.Error())
        os.Exit(1)
    }
}
$ go run example.go .. parent.lnk
make shortcut: .. --> parent.lnk
read shortcut: parent.lnk <-- C:\Users\hymko\go\src\github.com\nyaosorg

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Make

func Make(from, to, dir string) error

Make makes a shortcut file. `from`,`to` can be relative paths

func Read

func Read(path string) (targetPath string, workingDir string, err error)

Read reads the data of shortcut file. `path` can be relative path.

Types

This section is empty.

Directories

Path Synopsis
cmd
lnk

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL