wails icon indicating copy to clipboard operation
wails copied to clipboard

Allow to get AppID programmatically from go

Open brys0 opened this issue 3 years ago • 4 comments

Is your feature request related to a problem? Please describe.

For many purposes of binding notifications and background processes windows requires the appID to bind.

Describe the solution you'd like

Have the ability to get the AppID when running production through the app handle or something similar.

Describe alternatives you've considered

There would be no alternatives for this. Windows 11 makes it nearly impossible to get the AppID without creating and saving it programmatically.

Additional context

The appID should definitely be available for people want to extend wails basic functionality.

brys0 avatar Jul 19 '22 03:07 brys0

Happy to discuss this and accept a PR 👍

leaanthony avatar Jul 19 '22 09:07 leaanthony

Lovely, thanks sm! I think it'll be as simple as adding a field to the wails conf that's called "I'd"

brys0 avatar Jul 19 '22 12:07 brys0

Also, not exactly sure how nsis works, how would I create a variable in nsis that then the build of the wails project fills in with a value?

brys0 avatar Jul 19 '22 12:07 brys0

There's some metadata in wails.json that might suit your needs 👍

leaanthony avatar Jul 19 '22 12:07 leaanthony

If I'm understanding the problem correctly, I believe you can get this as follows:

package main

import (
	"fmt"
	"golang.org/x/sys/windows/registry"
)

func main() {
	appName := "YourApplicationName"
	keyPath := `SOFTWARE\Classes\AppID`

	key, err := registry.OpenKey(registry.LOCAL_MACHINE, keyPath, registry.READ)
	if err != nil {
		fmt.Printf("Failed to open registry key: %v\n", err)
		return
	}
	defer key.Close()

	appID, _, err := key.GetStringValue(appName)
	if err != nil {
		fmt.Printf("Failed to retrieve AppID: %v\n", err)
		return
	}

	fmt.Printf("AppID: %s\n", appID)
}

Closing for now. Please reopen if you can think of a good reason to make it a core functionality.

leaanthony avatar Jul 09 '23 22:07 leaanthony