Skip to content

Commit 02b9c88

Browse files
committed
Merge branch 'main' into aashcraft/main-cloud-files-add-copilot-plus-note
2 parents 8ec187d + 5c0b03d commit 02b9c88

4 files changed

Lines changed: 71 additions & 2 deletions

File tree

windows.storage/storagefile_contenttype.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,19 @@ public string ContentType { get; }
1010
# Windows.Storage.StorageFile.ContentType
1111

1212
## -description
13+
1314
Gets the MIME type of the contents of the file.
1415

1516
## -property-value
17+
1618
The MIME type of the file contents.
1719

18-
For example, a music file might have the "audio/mpeg" MIME type.
20+
For example, a music file might have the "audio/mpeg" MIME type.
1921

2022
## -remarks
2123

24+
The `ContentType` property provides an interpretation of the file extension to determine the MIME type. It does not inspect the actual contents of the file. For example, renaming a text file (`.txt`) to have a `.jpg` extension will result in the `ContentType` being reported as `image/jpeg`.
25+
2226
## -examples
2327

2428
## -see-also

windows.system.diagnostics/processdiagnosticinfo_getappdiagnosticinfos_212734444.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ public IVector<AppDiagnosticInfo> ProcessDiagnosticInfo.GetAppDiagnosticInfos()
1010
# Windows.System.Diagnostics.ProcessDiagnosticInfo.GetAppDiagnosticInfos
1111

1212
## -description
13+
1314
Gets one or more [AppDiagnosticInfo](/uwp/api/windows.system.appdiagnosticinfo) objects if the [IsPackaged](processdiagnosticinfo_ispackaged.md) property is **true**.
1415

1516
## -returns
17+
1618
Returns one or more [AppDiagnosticInfo](/uwp/api/windows.system.appdiagnosticinfo) objects.
1719

1820
## -remarks
21+
1922
Use of this method may require user consent, which defaults to denied. If you do not have consent, the method will return information for only the current app. Users can provide consent in Windows Settings. An app can request consent programmatically by calling [AppDiagnosticInfo.RequestAccessAsync](../windows.system/appdiagnosticinfo_requestaccessasync_380675631.md).
2023

2124
## -see-also
2225

2326
## -examples
24-

windows.system.diagnostics/processdiagnosticinfo_getforprocesses_1262014773.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,75 @@ public Windows.Foundation.Collections.IVectorView<Windows.System.Diagnostics.Pro
1010
# Windows.System.Diagnostics.ProcessDiagnosticInfo.GetForProcesses
1111

1212
## -description
13+
1314
Gets a list of [ProcessDiagnosticInfo](processdiagnosticinfo.md) objects for all running processes that are accessible to the caller.
1415

1516
## -returns
17+
1618
A list of [ProcessDiagnosticInfo](processdiagnosticinfo.md) objects for all running processes.
1719

1820
## -remarks
21+
1922
For UWP apps, processes must be in the same **AppContainer**.
2023

24+
To correlate `ProcessDiagnosticInfo` to `AppDiagnosticInfo` and retrieve the package name for a process, you can use the `AppDiagnosticInfo` class. The `AppDiagnosticInfo` class provides diagnostic information about an app, including its package details.
25+
26+
Here’s how you can retrieve the package name for a process:
27+
28+
1. Use the `ProcessDiagnosticInfo.GetForProcesses()` method to get a list of `ProcessDiagnosticInfo` objects.
29+
1. For each `ProcessDiagnosticInfo` object, call the `AppDiagnosticInfo.TryGetForProcess()` method to retrieve the associated `AppDiagnosticInfo`.
30+
1. Access the `AppInfo` property of the `AppDiagnosticInfo` object to get the `AppInfo` instance, which contains the package name.
31+
32+
The following example demonstrates how to achieve this:
33+
34+
```csharp
35+
using System;
36+
using System.Collections.Generic;
37+
using Windows.System.Diagnostics;
38+
using Windows.System;
39+
40+
class Program
41+
{
42+
static void Main(string[] args)
43+
{
44+
IReadOnlyList<ProcessDiagnosticInfo> processes = ProcessDiagnosticInfo.GetForProcesses();
45+
46+
foreach (var process in processes)
47+
{
48+
if (process.IsPackaged)
49+
{
50+
var appDiagnosticInfos = AppDiagnosticInfo.TryGetForProcess(process);
51+
52+
if (appDiagnosticInfos != null)
53+
{
54+
foreach (var appDiagnosticInfo in appDiagnosticInfos)
55+
{
56+
var appInfo = appDiagnosticInfo.AppInfo;
57+
if (appInfo != null)
58+
{
59+
Console.WriteLine($"Process ID: {process.ProcessId}, Package Name: {appInfo.PackageFamilyName}");
60+
}
61+
else
62+
{
63+
Console.WriteLine($"Process ID: {process.ProcessId} has no associated AppInfo.");
64+
}}");
65+
}
66+
}
67+
}
68+
else
69+
{
70+
Console.WriteLine($"Process ID: {process.ProcessId} is not associated with an app package.");
71+
}
72+
}
73+
}
74+
}
75+
```
76+
77+
Some things to note:
78+
79+
- The `IsPackaged` property indicates whether the process is part of a packaged app. If `IsPackaged` is `false`, the process is not associated with an app package, and `AppDiagnosticInfo.TryGetForProcess()` will return `null`.
80+
- Ensure your app has the necessary capabilities declared in the app manifest to access process and app diagnostic information.
81+
2182
## -examples
2283

2384
## -see-also

windows.system.diagnostics/processdiagnosticinfo_ispackaged.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ public bool IsPackaged { get; }
1010
# Windows.System.Diagnostics.ProcessDiagnosticInfo.IsPackaged
1111

1212
## -description
13+
1314
Gets a Boolean value indicating whether or not this [ProcessDiagnosticInfo](processdiagnosticinfo.md) instance has any related [UWP](/windows/uwp/get-started/universal-application-platform-guide) information.
1415

1516
## -property-value
17+
1618
A Boolean value indicating whether or not this [ProcessDiagnosticInfo](processdiagnosticinfo.md) instance has any related [UWP](/windows/uwp/get-started/universal-application-platform-guide) information.
1719

1820
## -remarks

0 commit comments

Comments
 (0)