Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在Windows 10中以编程方式启动语音记录器_C#_Powershell_Windows 10 - Fatal编程技术网

C# 在Windows 10中以编程方式启动语音记录器

C# 在Windows 10中以编程方式启动语音记录器,c#,powershell,windows-10,C#,Powershell,Windows 10,旧的“录音机”应用程序已被Windows 10应用商店应用程序“录音机”取代 我想使用PowerShell或C#以编程方式启动“语音记录器” 在Windows 10中启动语音记录器的shell命令是什么?从桌面启动AppX应用程序的正确方法是使用shell的方法 谢谢,我们将尝试分享反馈。快速问题-我希望Windows窗体应用程序由普通用户运行。我希望您的代码不需要任何管理员(提升)权限。它会为当前用户激活应用程序实例。没有管理员提示。@kamleshrao为您完成了这项工作?如果是的话,请投票

旧的“录音机”应用程序已被Windows 10应用商店应用程序“录音机”取代

我想使用PowerShell或C#以编程方式启动“语音记录器”


在Windows 10中启动语音记录器的shell命令是什么?

从桌面启动AppX应用程序的正确方法是使用shell的方法


谢谢,我们将尝试分享反馈。快速问题-我希望Windows窗体应用程序由普通用户运行。我希望您的代码不需要任何管理员(提升)权限。它会为当前用户激活应用程序实例。没有管理员提示。@kamleshrao为您完成了这项工作?如果是的话,请投票并接受作为答案。嗨@kamleshrao,你们有什么具体的理由启动语音记录器吗?我目前正在开发此应用程序,因此了解您在这里尝试解决的场景会有所帮助。您只是想让用户开始录制,还是希望将音频文件返回到您的解决方案中使用?@kamleshrao-您可以单击“下载LinqPad”链接,并在大约30秒内对其进行测试。如果尚未安装LinqPad,您可以在大约30秒内免费安装它:
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
{
}