如何获取“Windows应用程序的窗口句柄”使用win32 API? [英] How to get "Window Handle for Windows Store Apps" using win32 API?
问题描述
我正在使用Windows 8并使用C#.net作为编程语言。我正在尝试获取Windows Store App的Window Handle。我试图使用"Win32 API -EnumWindows"实现此目的。但我可以在Windows 8上列出所有Windows Handles,除了
for Windows商店应用程序。我理解这是因为Windows商店应用程序是沙箱。有没有办法获得Windows商店应用程序的窗口句柄?
$
下面是我用来获取所有Window句柄的代码,
[DllImport(" user32.dll")]
$
private static extern int EnumWindows(EnumWindowsCallBackDelegate callback,IntPtr lParam);
          public static IntPtr [] GetWindows
{
获得
{
跨度>列表与LT; IntPtr的> windowList = new List< IntPtr>();
GCHandle handle = GCHandle.Alloc(windowList);
尝试
{
EnumWindows(< EnumWindowsCallback>,(IntPtr)句柄);
}
最后是
{
handle.Free();
}
return windowList.ToArray();
}
}
Hi,
I am working on Windows 8 and using C#.net as programming language. I am trying to get the Window Handle for Windows Store App. I have tried to achieve this using "Win32 API -EnumWindows". But I am able to get all the Windows Handles listed on windows 8, except
for Windows store apps. I understand this is because the Windows store apps are sandboxed. Is there any way to to get the Window handle for Windows store apps?
Below is the code I am using to get all Window handles,
[DllImport("user32.dll")]
private static extern int EnumWindows(EnumWindowsCallBackDelegate callback, IntPtr lParam);
public static IntPtr[] GetWindows
{
get
{
List<IntPtr> windowList = new List<IntPtr>();
GCHandle handle = GCHandle.Alloc(windowList);
try
{
EnumWindows(<EnumWindowsCallback>, (IntPtr)handle);
}
finally
{
handle.Free();
}
return windowList.ToArray();
}
}
推荐答案
抱歉,这是不可能的。 Windows应用商店应用与HWND没有互动。
Sorry, That's not possible. Windows Store apps have no interaction with HWNDs.
这篇关于如何获取“Windows应用程序的窗口句柄”使用win32 API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!