public static string SidToPackageID(string sid) { string packageID = ""; if (!UwpFunc.IsWindows7OrLower) { IntPtr pSid = new IntPtr(); ConvertStringSidToSid(sid, ref pSid); //string test = ""; //ConvertSidToStringSid(pSid, ref test); int ret = UwpFunc.IsWindows8 ? AppModel8.AppContainerLookupMoniker(pSid, ref packageID) : AppModel.AppContainerLookupMoniker(pSid, ref packageID); Marshal.FreeHGlobal(pSid); } return(packageID); }