https://github.com/nyaosorg/go-windows-shortcut
Make or read shortcut-files on Windows
https://github.com/nyaosorg/go-windows-shortcut
go golang windows
Last synced: 9 months ago
JSON representation
Make or read shortcut-files on Windows
- Host: GitHub
- URL: https://github.com/nyaosorg/go-windows-shortcut
- Owner: nyaosorg
- License: mit
- Created: 2020-02-02T06:05:05.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-05-29T12:21:22.000Z (about 4 years ago)
- Last Synced: 2025-08-15T12:48:35.556Z (11 months ago)
- Topics: go, golang, windows
- Language: Go
- Homepage:
- Size: 12.7 KB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
go-windows-shortcut
===================
[](https://godoc.org/github.com/nyaosorg/go-windows-shortcut)
```go
// +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
```