获取其他窗口的SystemMediaTransportControls [英] Get SystemMediaTransportControls for other window
问题描述
我对 ISystemMediaTransportControlsInterop感兴趣: :GetForWindow 方法.该文档已经过时了.但是我在文件夹 C:\ Program Files(x86)\ Windows Kits \ 10 \ Include \ 10.0.19041.0中找到了 SystemMediaTransportControlsInterop.h 和 SystemMediaTransportControlsInterop.idl 文件Windows SDK的\ um .他们正在描述GetForWindow
方法.那么,如何获取ISystemMediaTransportControlsInterop
的实例并调用此方法?
I'm interesting in ISystemMediaTransportControlsInterop::GetForWindow method. The documentation is outdated for it. But I have found files SystemMediaTransportControlsInterop.h and SystemMediaTransportControlsInterop.idl in folder C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um of Windows SDK. They are describing GetForWindow
method. So, how can I get an instance of ISystemMediaTransportControlsInterop
and call this method?
WinRT仅包含方法 SystemMediaTransportControls.GetForCurrentView ,但是我想从我的应用程序中为其他程序获取SystemMediaTransportControls
的实例.
WinRT contains only method SystemMediaTransportControls.GetForCurrentView, but I want to get an instance of SystemMediaTransportControls
for other program from my application.
谢谢
推荐答案
因此,我发现 WinRT 是基于 COM 技术的.而且我们可以从互操作接口获得ActivationFactory
来调用方法.
例如,在C#上:
So, I have found, that WinRT is based on COM technology. And we can get ActivationFactory
to call method from interop interface.
For example, on C#:
[Guid("ddb0472d-c911-4a1f-86d9-dc3d71a95f5a")]
[InterfaceType(ComInterfaceType.InterfaceIsIInspectable)]
public interface ISystemMediaTransportControlsInterop
{
SystemMediaTransportControls GetForWindow(IntPtr Window, [In] ref Guid riid);
}
var smtcInterop = (ISystemMediaTransportControlsInterop)WindowsRuntimeMarshal.GetActivationFactory(typeof(SystemMediaTransportControls));
var guid = typeof(SystemMediaTransportControls).GUID;
var smtc = smtcInterop.GetForWindow(hwnd, ref guid);
但是问题是,如果我尝试其他窗口的 SMTC 实例,则会收到拒绝访问的异常.
But the problem is, that I receive access denied exception if I try SMTC instance of other window.
这篇关于获取其他窗口的SystemMediaTransportControls的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!