你可以看看這個庫:https://github.com/dahall/Vanara/它提供了P/Invoke。 他們是這樣實施的: [DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]public static extern long GetPackagesByPackageFamily(string packageFamilyName, ref uint count, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 1)] string[] packageFullNames, ref uint bufferLength, IntPtr buffer); (見此處https://github.com/dahall/Vanara/blob/3f64f6d9d4c963070e31823ca8a720068ac07fe2/PInvoke/Kernel32/AppModel.cs)