Jump to content

Search the Community

Showing results for tags 'getpackagesbypackagefamily'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. #include <WinAPIMisc.au3> #include <ApiErrorsConstants.au3> Exit ConsoleWrite(@CRLF & _GetWindowsNotepadPath() & @CRLF & @CRLF) Func _GetWindowsNotepadPath() Local $asPackageNames = _WinAPI_GetPackagesByPackageFamily("Microsoft.WindowsNotepad_8wekyb3d8bbwe") If @error Then Return SetError(1, 0, @WindowsDir & "\notepad.exe") Local $sPathByFullName = _WinAPI_GetPackagePathByFullName($asPackageNames[1]) If @error Then Return SetError(2, 0, @WindowsDir & "\notepad.exe") Return $sPathByFullName & "\Notepad\notepad.exe" EndFunc ;==>_GetWindowsNotepadPath Func _WinAPI_GetPackagesByPackageFamily($sFamilyName) Local $aCall = DllCall("kernel32.dll", "long", "GetPackagesByPackageFamily", "wstr", $sFamilyName, "uint*", 0, "ptr", 0, "uint*", 0, "ptr", 0) If @error Or ($aCall[0] <> $ERROR_INSUFFICIENT_BUFFER) Then Return SetError(1) ;Bad call or unexpected error Local $iCount = $aCall[2], $iBuffSize = $aCall[4] If (Not $iCount) Or (Not $iBuffSize) Then Return SetError(2) ;No retrievable data Local $tNameLocations = DllStructCreate("ptr Address[" & $iCount & "]") Local $tBuffer = DllStructCreate("wchar[" & $iBuffSize & "]") $aCall = DllCall("kernel32.dll", "long", "GetPackagesByPackageFamily", _ "wstr", $sFamilyName, "uint*", $iCount, "struct*", $tNameLocations, "uint*", $iBuffSize, "struct*", $tBuffer) If @error Or $aCall[0] Then Return SetError(3) ;Bad Call of $aCall[0] <> ERROR_SUCCESS Local $asNames[$iCount + 1] = [$iCount], $tPackageName, $iNameLen, $pNameAddress For $i = 1 To $iCount $pNameAddress = $tNameLocations.Address(($i)) $iNameLen = _WinAPI_StringLenW($pNameAddress) $tPackageName = DllStructCreate("wchar Name[" & $iNameLen & "]", $pNameAddress) $asNames[$i] = $tPackageName.Name Next Return $asNames EndFunc ;==>_WinAPI_GetPackagesByPackageFamily Func _WinAPI_GetPackagePathByFullName($sPackageName) Local $aCall = DllCall("kernel32.dll", "long", "GetPackagePathByFullName", "wstr", $sPackageName, "uint*", 0, "ptr", 0) If @error Or ($aCall[0] <> $ERROR_INSUFFICIENT_BUFFER) Then Return SetError(1) Local $iBuffSize = $aCall[2] If Not $iBuffSize Then Return SetError(2) ;No retrievable data Local $tPath = DllStructCreate("wchar Path[" & $iBuffSize & "]") $aCall = DllCall("kernel32.dll", "long", "GetPackagePathByFullName", "wstr", $sPackageName, "uint*", $iBuffSize, "struct*", $tPath) If @error Or $aCall[0] Then Return SetError(3) Return $tPath.Path EndFunc ;==>_WinAPI_GetPackagePathByFullName Maybe it should be 2 functions, one for GetPackagesByPackageFamily and one for GetPackagePathByFullName ?. In any case, I don't see a reason to separate them. What would be the use 🤔 Thanks to @MattyD we now have proper code With this you can get the path to: "Microsoft.WindowsNotepad_8wekyb3d8bbwe" or "Microsoft.WindowsTerminal_8wekyb3d8bbwe" or anything else from the windows store. If you feel this should be different, say it. Am not a magician ( well, maybe flowers out of a stick but that's unrelated to the topic ).
×
×
  • Create New...