返回 DeepSeek-Reasonix
shortcut_fields_windows.go
根目录 / internal / appidentity / shortcut_fields_windows.go
1 //go:build windows
2
3 package appidentity
4
5 import (
6 "syscall"
7 "unsafe"
8
9 "golang.org/x/sys/windows"
10 )
11
12 func (s *loadedShortcut) setString(method uintptr, value string) error {
13 pointer, err := windows.UTF16PtrFromString(value)
14 if err != nil {
15 return err
16 }
17 hr, _, _ := syscall.SyscallN(method, uintptr(unsafe.Pointer(s.link)), uintptr(unsafe.Pointer(pointer)))
18 return checkHRESULT("IShellLinkW string update", hr)
19 }
20
21 func (s *loadedShortcut) iconLocation() (string, int32, error) {
22 buffer := make([]uint16, windowsPathBuffer)
23 var index int32
24 hr, _, _ := syscall.SyscallN(s.link.VTable.GetIconLocation, uintptr(unsafe.Pointer(s.link)),
25 uintptr(unsafe.Pointer(&buffer[0])), uintptr(len(buffer)), uintptr(unsafe.Pointer(&index)))
26 return windows.UTF16ToString(buffer), index, checkHRESULT("IShellLinkW.GetIconLocation", hr)
27 }
28
29 func (s *loadedShortcut) setIconLocation(path string, index int32) error {
30 pointer, err := windows.UTF16PtrFromString(path)
31 if err != nil {
32 return err
33 }
34 hr, _, _ := syscall.SyscallN(s.link.VTable.SetIconLocation, uintptr(unsafe.Pointer(s.link)),
35 uintptr(unsafe.Pointer(pointer)), uintptr(index))
36 return checkHRESULT("IShellLinkW.SetIconLocation", hr)
37 }
38
38 lines GO