diff --git a/syscallex/shell32_windows.go b/syscallex/shell32_windows.go index 6633656..e68d169 100644 --- a/syscallex/shell32_windows.go +++ b/syscallex/shell32_windows.go @@ -17,6 +17,7 @@ const ( CSIDL_APPDATA = 0x001a CSIDL_PROFILE = 0x0028 CSIDL_LOCAL_APPDATA = 0x001c + CSIDL_STARTMENU = 0x000b ) const MAX_PATH = 260 diff --git a/winox/users_windows.go b/winox/users_windows.go index 6fed1e8..af75e80 100644 --- a/winox/users_windows.go +++ b/winox/users_windows.go @@ -16,6 +16,7 @@ const ( FolderTypeProfile FolderType = iota FolderTypeAppData FolderTypeLocalAppData + FolderTypeStartMenu ) func GetFolderPath(folderType FolderType) (string, error) { @@ -27,6 +28,8 @@ func GetFolderPath(folderType FolderType) (string, error) { csidl = syscallex.CSIDL_APPDATA case FolderTypeLocalAppData: csidl = syscallex.CSIDL_LOCAL_APPDATA + case FolderTypeStartMenu: + csidl = syscallex.CSIDL_STARTMENU default: return "", errors.Errorf("Unknown folder type: %d", folderType) } diff --git a/winox/users_windows_test.go b/winox/users_windows_test.go index 83eb8ca..949940d 100644 --- a/winox/users_windows_test.go +++ b/winox/users_windows_test.go @@ -8,10 +8,24 @@ import ( ) func Test_GetFolderPath(t *testing.T) { - { - s, err := winox.GetFolderPath(winox.FolderTypeProfile) - assert.NoError(t, err) - assert.NotEmpty(t, s) + type tcase struct { + name string + typ winox.FolderType + } + + cases := []tcase{ + tcase{name: "appData", typ: winox.FolderTypeAppData}, + tcase{name: "localAppData", typ: winox.FolderTypeLocalAppData}, + tcase{name: "profile", typ: winox.FolderTypeProfile}, + tcase{name: "startMenu", typ: winox.FolderTypeStartMenu}, + } + + for _, cas := range cases { + t.Run(cas.name, func(t *testing.T) { + s, err := winox.GetFolderPath(cas.typ) + assert.NoError(t, err) + assert.NotEmpty(t, s) + }) } {