nwin

package
v1.31.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Rendered for windows/amd64

Index

Constants

View Source
const RegDateFormat = "20060102"

RegDateFormat is the format in which installed time should be stored in the registry, as a format string suitable for time.Format()

Variables

View Source
var ErrElevationCancelled = fmt.Errorf("elevation cancelled by user")

Functions

func CenterWindow

func CenterWindow(mw *walk.FormBase)

func CreateShortcut

func CreateShortcut(settings ShortcutSettings) error

CreateShortcut creates a windows shortcut with the given settings

func CreateUninstallRegistryEntry

func CreateUninstallRegistryEntry(cli cl.CLI, user *UserProfile, installDir string, version string) error

CreateUninstallRegistryEntry creates all registry entries required to have the app show up in Add or Remove software and be uninstalled by the user

func DesktopUserCanWrite added in v1.31.0

func DesktopUserCanWrite(dir string) (bool, error)

DesktopUserCanWrite reports whether the ordinary interactive user can create files in dir. It only means something when we run elevated: an elevated installer can write anywhere, but later updates run as the plain user.

func GetModuleFileName

func GetModuleFileName(hprocess syscall.Handle) (string, error)

func GetRegistryInstallDir

func GetRegistryInstallDir(cli cl.CLI, user *UserProfile) (string, error)

func GetShortcutTarget added in v1.31.0

func GetShortcutTarget(shortcutFilePath string) (string, error)

GetShortcutTarget reads the target path of an existing .lnk file. Returns an empty string (and no error) if the link stores no target.

func IsElevated added in v1.31.0

func IsElevated() bool

IsElevated returns true if this process runs with a full administrator token (UAC-elevated, or UAC disabled for an admin account).

func KillAll

func KillAll(pathsToKill []string) error

func ListProcessModulePaths added in v1.31.0

func ListProcessModulePaths() ([]setup.RunningProcess, error)

ListProcessModulePaths enumerates all processes along with the paths of their executable and loaded modules. Processes we can't inspect (access denied, exited mid-enumeration) are skipped or reported with whatever paths could be determined.

func LoadImage

func LoadImage(filePath string) walk.Image

func RectangleFromRECT

func RectangleFromRECT(r win.RECT) walk.Rectangle

func RegisterURLProtocols added in v1.31.0

func RegisterURLProtocols(cli cl.CLI, user *UserProfile, launcherPath string) error

RegisterURLProtocols registers the app's URL schemes (per-user) to open through the stable launcher rather than a versioned app-X.Y.Z executable, which would go stale on the next self-update.

func RelaunchElevated added in v1.31.0

func RelaunchElevated(args []string) error

RelaunchElevated starts this executable again through UAC with the given arguments and returns without waiting for it. The user declining the prompt is reported as ErrElevationCancelled.

func RemoveUninstallerRegistryKey

func RemoveUninstallerRegistryKey(cli cl.CLI, user *UserProfile) error

func SetInstallerImage

func SetInstallerImage(cli cl.CLI, imageView *walk.ImageView)

func StartProcessAsDesktopUser added in v1.31.0

func StartProcessAsDesktopUser(exe string, args []string, dir string) error

StartProcessAsDesktopUser launches exe as the ordinary interactive user, for when we run elevated and must not hand our administrator token down to the app.

func URLProtocols added in v1.31.0

func URLProtocols(appName string) []string

URLProtocols returns the URL schemes an app handles.

Types

type DWORDValue

type DWORDValue struct {
	Key   string
	Value uint32
}

type Folders

type Folders struct {
	LocalAppData   string
	RoamingAppData string
	Desktop        string
	Programs       string
}

func GetFolders

func GetFolders() (f Folders, err error)

type ShortcutSettings

type ShortcutSettings struct {
	ShortcutFilePath string
	TargetPath       string
	Arguments        string
	Description      string
	IconLocation     string
	WorkingDirectory string
	OnlyIfExists     bool
	AppUserModelId   string
}

type StringValue

type StringValue struct {
	Key   string
	Value string
}

type UserProfile added in v1.31.0

type UserProfile struct {
	// contains filtered or unexported fields
}

UserProfile is the account that per-user integration (folders, shortcuts, HKCU keys) belongs to. Normally that's whoever we run as. When we run elevated on the desktop user's behalf it's still them: a standard user entering an administrator's credentials at the UAC prompt gets a child running under that administrator's profile.

func CurrentUserProfile added in v1.31.0

func CurrentUserProfile() *UserProfile

CurrentUserProfile uses the profile of the current process.

func DesktopUserProfile added in v1.31.0

func DesktopUserProfile() (*UserProfile, error)

DesktopUserProfile uses the profile of the interactive user of our session, for when we run elevated.

func (*UserProfile) Close added in v1.31.0

func (u *UserProfile) Close()

func (*UserProfile) Folders added in v1.31.0

func (u *UserProfile) Folders() (Folders, error)

Folders returns the profile's well-known folders, creating any that are missing.

func (*UserProfile) String added in v1.31.0

func (u *UserProfile) String() string

Jump to

Keyboard shortcuts

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