C#:如何打开配置 Pin 对话框?

发布于 2024-10-12 00:10:58 字数 258 浏览 2 评论 0原文

我想知道

 System.Diagnostics.Process.Start("", "");

打开此对话框时要运行什么进程。谢谢 替代文字 该对话框来自MS Expression编码器的直播项目,所选设备的配置引脚对话框。 替代文字

I want to know what process to run with

 System.Diagnostics.Process.Start("", "");

that open this dialog. Thank you
alt text
This dialog come from Live broadcasting project of MS Expression encoder, Config pin Dialog of selected device.
alt text

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

阳光的暖冬 2024-10-19 00:10:58

此对话框不是一个单独的可执行文件,您可以使用 System.Diagnostics.Process.Start 运行它。这是捕获设备的配置对话框。您的捕获设备表示为 DirectShow 捕获设备。此设备是一个 COM 对象,它实现 ISpecifyPropertyPages,这是您正在查看的特定屏幕的来源。 这里是一篇有关如何显示的 MSDN 文章DirectShow 过滤器的属性页。

This dialog is not a separate executable that you can just run with System.Diagnostics.Process.Start. This is a configuration dialog for your capture device. Your capture device is represented as DirectShow capture device. This device is a COM object which implements the ISpecifyPropertyPages, which is where the specific screen you are looking at comes from. Here is an MSDN article on how to display a DirectShow filter's property page.

痴情 2024-10-19 00:10:58

如果您使用的是 Expression Encoder SDK 4,则可以显示此对话框和其他配置窗口,如下所示:

 LiveDeviceSource _deviceSource;   
 ....
 if (_deviceSource.IsDialogSupported(ConfigurationDialog.VideoCapturePinDialog))
 {              
       _deviceSource.ShowConfigurationDialog(ConfigurationDialog.VideoCapturePinDialog, (new HandleRef(panelVideoPreview, panelVideoPreview.Handle)));
 }

您可以通过探索 Microsoft.Expression.Encoder.Live.ConfigurationDialog 类型来查看支持的所有配置对话框。

If you are using Expression Encoder SDK 4, then you can show this dialog and other configuration windows as follows:

 LiveDeviceSource _deviceSource;   
 ....
 if (_deviceSource.IsDialogSupported(ConfigurationDialog.VideoCapturePinDialog))
 {              
       _deviceSource.ShowConfigurationDialog(ConfigurationDialog.VideoCapturePinDialog, (new HandleRef(panelVideoPreview, panelVideoPreview.Handle)));
 }

You can see all the configuration dialogs supported by exploring Microsoft.Expression.Encoder.Live.ConfigurationDialog type.

季末如歌 2024-10-19 00:10:58

没有任何程序可以使用该行运行来打开该对话框。 (当然,除非你自己做了一个。)

There is no program that you can run with that line to bring up that dialog. (Unless you make one, of course.)

给妤﹃绝世温柔 2024-10-19 00:10:58

使用 Expression Encoder SDK 中的 LiveDeviceSource.ShowConfigurationDialog 函数通常是一个不错的选择。然而,就我而言,我有一些捕获源,如果配置错误,则无法由表达式编码器正确实例化。为了正确配置它们,我需要它们的配置对话框。因此,我使用 DirectShow.NET 整合了这个解决方案:

/// <summary>
/// Retrieves the IBaseFilter with the requested name
/// </summary>
/// <param name="deviceName">The friendly name of the device to retrieve</param>
/// <param name="deviceType">The type of device to retrieve</param>
/// <returns>Returns the filter with the given friendly name, or null if no such filter exists</returns>
public static IBaseFilter GetDeviceFilterByName(string deviceName, EncoderDeviceType deviceType)
{
    int hr = 0;
    IEnumMoniker classEnum = null;
    IMoniker[] moniker = new IMoniker[1];

    // Create the system device enumerator
    ICreateDevEnum devEnum = (ICreateDevEnum)new CreateDevEnum();

    // Create an enumerator for the video or audio capture devices
    if (deviceType == EncoderDeviceType.Audio)
    {
        hr = devEnum.CreateClassEnumerator(FilterCategory.AudioInputDevice, out classEnum, 0);
    } else
    {
        hr = devEnum.CreateClassEnumerator(FilterCategory.VideoInputDevice, out classEnum, 0);
    }

    DsError.ThrowExceptionForHR(hr);
    Marshal.ReleaseComObject(devEnum);

    // no enumerators for video/audio input devices
    if (classEnum == null)
    {
        return null;
    }

    IBaseFilter foundFilter = null;
    // enumerate all input devices, looking for one with the desired friendly name
    while(classEnum.Next(moniker.Length, moniker, IntPtr.Zero) == 0)
    {
        Guid iid = typeof(IPropertyBag).GUID;
        object props;
        moniker[0].BindToStorage(null, null, ref iid, out props);
        object currentName;
        (props as IPropertyBag).Read("FriendlyName", out currentName, null);

        if ((string)currentName == deviceName)
        {
            object filter;
            iid = typeof(IBaseFilter).GUID;
            moniker[0].BindToObject(null, null, ref iid, out filter);
            foundFilter = (IBaseFilter)filter;

            Marshal.ReleaseComObject(moniker[0]);
            break;
        }
        Marshal.ReleaseComObject(moniker[0]);
    }

    Marshal.ReleaseComObject(classEnum);
    return foundFilter;
}

/// <summary>
/// Opens the property pages for the filter with the given name
/// </summary>
/// <param name="filter">The filter for which we wish to retrieve and open the property pages</param>
public static void ShowDevicePropertyPages(IBaseFilter filter, IntPtr handle)
{
    // get the ISpecifyPropertyPages for the filter
    ISpecifyPropertyPages pProp = filter as ISpecifyPropertyPages;
    int hr = 0;
    if (pProp == null)
    {
        // if the filter doesn't implement ISpecifyPropertyPages, try displaying IAMVfwCompressDialogs instead
        IAMVfwCompressDialogs compressDialog = filter as IAMVfwCompressDialogs;
        if (compressDialog != null)
        {
            hr = compressDialog.ShowDialog(VfwCompressDialogs.Config, IntPtr.Zero);
            DsError.ThrowExceptionForHR(hr);
        }
        return;
    }

    // get the name of the filter from the FilterInfo struct
    FilterInfo filterInfo;
    hr = filter.QueryFilterInfo(out filterInfo);
    DsError.ThrowExceptionForHR(hr);

    // get the propertypages from the property bag
    DsCAUUID caGUID;
    hr = pProp.GetPages(out caGUID);
    DsError.ThrowExceptionForHR(hr);

    // create and display the OlePropertyFrame
    object[] oDevice = new[] {(object)filter};
    hr = OleCreatePropertyFrame(handle, 0, 0, filterInfo.achName, 1, oDevice,
                                caGUID.cElems, caGUID.ToGuidArray(), 0, 0, 0);
    DsError.ThrowExceptionForHR(hr);

    // release COM objects
    Marshal.FreeCoTaskMem(caGUID.pElems);
    Marshal.ReleaseComObject(pProp);
    if (filterInfo.pGraph != null)
    {
        Marshal.ReleaseComObject(filterInfo.pGraph);
    }
}

[DllImport("oleaut32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int OleCreatePropertyFrame(IntPtr hwndOwner,
    int x,
    int y,
    [MarshalAs(UnmanagedType.LPWStr)] string lpszCaption,
    int cObjects,
    [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4, ArraySubType = UnmanagedType.IUnknown)] object[] lplpUnk,
    int cPages,
    [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 6)] Guid[] lpPageClsID,
    int lcid,
    int dwReserved,
    int lpvReserved);

用法:

var device = GetDeviceFilterByName(_settingsViewModel.VideoEncoderDevice.Name, EncoderDeviceType.Video);
ShowDevicePropertyPages(device, new HandleRef(ConfigurationDialogHost, 
                    ConfigurationDialogHost.Handle).Handle);

Using the LiveDeviceSource.ShowConfigurationDialog function from the Expression Encoder SDK is usually a good choice. In my case, however, I had some capture sources that could not be properly instantiated by Expression Encoder if they are mis-configured. To configure them properly, I needed their configuration dialogs. So, I pulled together this solution using DirectShow.NET:

/// <summary>
/// Retrieves the IBaseFilter with the requested name
/// </summary>
/// <param name="deviceName">The friendly name of the device to retrieve</param>
/// <param name="deviceType">The type of device to retrieve</param>
/// <returns>Returns the filter with the given friendly name, or null if no such filter exists</returns>
public static IBaseFilter GetDeviceFilterByName(string deviceName, EncoderDeviceType deviceType)
{
    int hr = 0;
    IEnumMoniker classEnum = null;
    IMoniker[] moniker = new IMoniker[1];

    // Create the system device enumerator
    ICreateDevEnum devEnum = (ICreateDevEnum)new CreateDevEnum();

    // Create an enumerator for the video or audio capture devices
    if (deviceType == EncoderDeviceType.Audio)
    {
        hr = devEnum.CreateClassEnumerator(FilterCategory.AudioInputDevice, out classEnum, 0);
    } else
    {
        hr = devEnum.CreateClassEnumerator(FilterCategory.VideoInputDevice, out classEnum, 0);
    }

    DsError.ThrowExceptionForHR(hr);
    Marshal.ReleaseComObject(devEnum);

    // no enumerators for video/audio input devices
    if (classEnum == null)
    {
        return null;
    }

    IBaseFilter foundFilter = null;
    // enumerate all input devices, looking for one with the desired friendly name
    while(classEnum.Next(moniker.Length, moniker, IntPtr.Zero) == 0)
    {
        Guid iid = typeof(IPropertyBag).GUID;
        object props;
        moniker[0].BindToStorage(null, null, ref iid, out props);
        object currentName;
        (props as IPropertyBag).Read("FriendlyName", out currentName, null);

        if ((string)currentName == deviceName)
        {
            object filter;
            iid = typeof(IBaseFilter).GUID;
            moniker[0].BindToObject(null, null, ref iid, out filter);
            foundFilter = (IBaseFilter)filter;

            Marshal.ReleaseComObject(moniker[0]);
            break;
        }
        Marshal.ReleaseComObject(moniker[0]);
    }

    Marshal.ReleaseComObject(classEnum);
    return foundFilter;
}

/// <summary>
/// Opens the property pages for the filter with the given name
/// </summary>
/// <param name="filter">The filter for which we wish to retrieve and open the property pages</param>
public static void ShowDevicePropertyPages(IBaseFilter filter, IntPtr handle)
{
    // get the ISpecifyPropertyPages for the filter
    ISpecifyPropertyPages pProp = filter as ISpecifyPropertyPages;
    int hr = 0;
    if (pProp == null)
    {
        // if the filter doesn't implement ISpecifyPropertyPages, try displaying IAMVfwCompressDialogs instead
        IAMVfwCompressDialogs compressDialog = filter as IAMVfwCompressDialogs;
        if (compressDialog != null)
        {
            hr = compressDialog.ShowDialog(VfwCompressDialogs.Config, IntPtr.Zero);
            DsError.ThrowExceptionForHR(hr);
        }
        return;
    }

    // get the name of the filter from the FilterInfo struct
    FilterInfo filterInfo;
    hr = filter.QueryFilterInfo(out filterInfo);
    DsError.ThrowExceptionForHR(hr);

    // get the propertypages from the property bag
    DsCAUUID caGUID;
    hr = pProp.GetPages(out caGUID);
    DsError.ThrowExceptionForHR(hr);

    // create and display the OlePropertyFrame
    object[] oDevice = new[] {(object)filter};
    hr = OleCreatePropertyFrame(handle, 0, 0, filterInfo.achName, 1, oDevice,
                                caGUID.cElems, caGUID.ToGuidArray(), 0, 0, 0);
    DsError.ThrowExceptionForHR(hr);

    // release COM objects
    Marshal.FreeCoTaskMem(caGUID.pElems);
    Marshal.ReleaseComObject(pProp);
    if (filterInfo.pGraph != null)
    {
        Marshal.ReleaseComObject(filterInfo.pGraph);
    }
}

[DllImport("oleaut32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int OleCreatePropertyFrame(IntPtr hwndOwner,
    int x,
    int y,
    [MarshalAs(UnmanagedType.LPWStr)] string lpszCaption,
    int cObjects,
    [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4, ArraySubType = UnmanagedType.IUnknown)] object[] lplpUnk,
    int cPages,
    [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 6)] Guid[] lpPageClsID,
    int lcid,
    int dwReserved,
    int lpvReserved);

Usage:

var device = GetDeviceFilterByName(_settingsViewModel.VideoEncoderDevice.Name, EncoderDeviceType.Video);
ShowDevicePropertyPages(device, new HandleRef(ConfigurationDialogHost, 
                    ConfigurationDialogHost.Handle).Handle);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文