简体   繁体   English

以编程方式在Windows 10中启动录音机

[英]Launch Voice Recorder in Windows 10 programmatically

The good old "Sound Recorder" application has been replaced with Windows 10 Store App "Voice Recorder". 良好的旧“录音机”应用程序已被Windows 10商店应用程序“录音机”取代。

I want to launch "Voice Recorder" programmatically using PowerShell or C#. 我想使用PowerShell或C#以编程方式启动“ Voice Recorder”。

What is the shell command to launch the Voice Recorder in Windows 10? 在Windows 10中启动录音机的shell命令是什么?

The correct way to launch an AppX app from the desktop is to use the shell's IApplicationActivationManager::ActivateApplication method. 从桌面启动AppX应用程序的正确方法是使用外壳程序的IApplicationActivationManager::ActivateApplication方法。

void Main()
{
    var mgr = new ApplicationActivationManager();
    uint processId;
    var name = "Microsoft.WindowsSoundRecorder_8wekyb3d8bbwe!App";
    mgr.ActivateApplication(name, null, ActivateOptions.None, out processId);
}

public enum ActivateOptions
{
    None = 0x00000000,  // No flags set
    DesignMode = 0x00000001,  // The application is being activated for design mode, and thus will not be able to
    // to create an immersive window. Window creation must be done by design tools which
    // load the necessary components by communicating with a designer-specified service on
    // the site chain established on the activation manager.  The splash screen normally
    // shown when an application is activated will also not appear.  Most activations
    // will not use this flag.
    NoErrorUI = 0x00000002,  // Do not show an error dialog if the app fails to activate.
    NoSplashScreen = 0x00000004,  // Do not show the splash screen when activating the app.
}

[ComImport, Guid("2e941141-7f97-4756-ba1d-9decde894a3d"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IApplicationActivationManager
{
    // Activates the specified immersive application for the "Launch" contract, passing the provided arguments
    // string into the application.  Callers can obtain the process Id of the application instance fulfilling this contract.
    IntPtr ActivateApplication([In] String appUserModelId, [In] String arguments, [In] ActivateOptions options, [Out] out UInt32 processId);
    IntPtr ActivateForFile([In] String appUserModelId, [In] [MarshalAs(UnmanagedType.Interface, IidParameterIndex = 2)] /*IShellItemArray* */ IShellItemArray itemArray, [In] String verb, [Out] out UInt32 processId);
    IntPtr ActivateForProtocol([In] String appUserModelId, [In] IntPtr /* IShellItemArray* */itemArray, [Out] out UInt32 processId);
}

[ComImport, Guid("45BA127D-10A8-46EA-8AB7-56EA9078943C")]//Application Activation Manager
class ApplicationActivationManager : IApplicationActivationManager
{
    [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)/*, PreserveSig*/]
    public extern IntPtr ActivateApplication([In] String appUserModelId, [In] String arguments, [In] ActivateOptions options, [Out] out UInt32 processId);
    [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
    public extern IntPtr ActivateForFile([In] String appUserModelId, [In] [MarshalAs(UnmanagedType.Interface, IidParameterIndex = 2)]  /*IShellItemArray* */ IShellItemArray itemArray, [In] String verb, [Out] out UInt32 processId);
    [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
    public extern IntPtr ActivateForProtocol([In] String appUserModelId, [In] IntPtr /* IShellItemArray* */itemArray, [Out] out UInt32 processId);
}

[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("43826d1e-e718-42ee-bc55-a1e261c37bfe")]
interface IShellItem
{
}

[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("b63ea76d-1f85-456f-a19c-48159efa858b")]
interface IShellItemArray
{
}

Download this code for LinqPad 下载此代码以使用LinqPad

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 启动Windows录音机应用程序 - Launch windows sound recorder app 如何以编程方式从我的 Windows 10 应用程序启动相机应用程序? - How to launch camera app from my windows 10 app programmatically? Windows 以编程方式访问语音命令 - Windows Voice Access commands programmatically 在 Windows 10 上,如何使用 shell 执行动词“SendTo”以编程方式从 C# 将一组文件发送到 CD/DVD 刻录机 - On Windows 10, how to send programmatically from C# a set of files to the CD/DVD recorder using the shell execution verb "SendTo" 在Cortana中具有语音命令的Windows Phone启动应用 - Windows Phone Launch App with Voice Commands in Cortana Windows Mobile 6.5以编程方式启动蓝牙管理器 - Windows Mobile 6.5 launch bluetooth manager programmatically 如何以编程方式在Windows Phone中启动Skype? - How to programmatically launch Skype in Windows Phone? Windows 7/10-使应用程序在其他显示器上启动 - Windows 7/10 - Make Application launch on a different display 无法启动Windows 10移动模拟器 - Cannot launch windows 10 mobile emulator 以编程方式突出显示Universal Windows 10中的ListView元素 - Programmatically highlight ListView element in Universal Windows 10
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM