我有一个Windows CE嵌入式6.0应用程序,在后台打开另一个应用程序,我想把另一个应用程序放在前面。我第一次尝试使用第三方应用程序的MainWindowHandle SetParent,它没有工作。然后,我再次在同一个MainWindowHandle上尝试了SetActiveWindow,它没有工作。这让我相信MainWindowHandle已经搞乱了,当我在控制台上打印它时,它始终为0.这让我想起了第一个问题:应用程序的开发人员忘记提及MainWindow是什么可能吗?或者它是在.NET中自动分配的?其次,现在这种方法失败了,我尝试使用EnumWindows,然后为每个窗口获取ID并将其与我所知道的我需要的程序的ID进行匹配。这给了我一个异常0x80131515说不支持“EnumWindows”。我已经从CoreDll导入EnumWindows就好了。第二个问题:可能是这个错误的原因是什么?我究竟做错了什么?窗口前景无窗口把手
对不起!下面是一些代码(假设VCProcess已经开始):
[DllImport("coredll.dll")]
static extern int EnumWindows(CallbackDef callback, int lParam);
[DllImport("coredll.dll")]
static extern int GetWindowThreadProcessId(IntPtr hWnd, int pid);
static void Main()
{
callBackPtr = new CallBackPtr(Report);
EnumWindows(callBackPtr, 0);
}
public static bool Report(int hwnd, int lParam)
{
int pid = 0;
GetWindowThreadProcessId(hWnd, pid);
if (pid == VCProcessId)
{
SetForegroundWindow(hWnd);
}
MessageBox.show("Window handle is "+hwnd);
return true;
}
问题是缺少重要的东西:代码。 – user7116 2011-04-18 21:25:50