多くの Web ブラウザーでは、ユーザーの履歴が保存されない "InPrivate" ブラウズの概念がサポートされています。
このようなモードで Recall ユーザーの閲覧履歴が保存されないようにするには、アプリで SetInputScope 関数を使用し、入力スコープを IS_PASSWORD に設定します。
Important
また、アプリがこの記事で説明されている動作をサポートするためには、http またはhttps プロトコルハンドラーがSetInputScope に登録されている必要があります。
[DllImport("msctf.dll", SetLastError = true)]
private static extern int SetInputScope(IntPtr hwnd, InputScope inputScope);
private new enum InputScope : int
{
IS_DEFAULT = 0,
IS_URL = 1,
IS_FILE_FULLFILEPATH = 2,
IS_PRIVATE = 0x1f // Input is treated as private (e.g. passwords)
}
private void EnterInPrivateMode()
{
// Get your HWND. This will vary based on your UI Framework. WPF can use WindowInteropHelper, passing in your current Window.
IntPtr hwnd = new WindowInteropHelper(this).Handle;
// Then, set the input scope on the HWND to private
SetInputScope(hwnd, InputScope.IS_PRIVATE);
}
private void ExitInPrivateMode()
{
// Get your HWND. This will vary based on your UI Framework. WPF can use WindowInteropHelper, passing in your current Window.
IntPtr hwnd = new WindowInteropHelper(this).Handle;
// Then, set the input scope on the HWND to default
SetInputScope(hwnd, InputScope.IS_DEFAULT);
}
ユーザーが "プライベート" 閲覧モードである間、アプリはユーザー アクティビティの提供を中断する必要があります。
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
Windows developer