问题描述
我正在使用createprocess执行一个应用程序,例如记事本.
I'm executing an application say notepad, using createprocess.
我需要覆盖该应用程序的默认大小和位置,因此我修改了STARTUPINFO,并指定了dwX,dwY,dwYSize,dwXSize并向dwFlags添加了STARTF_USEPOSITION || STARTF_USESIZE.
I need to override the default size and position of that application so i modified STARTUPINFO, and specified dwX,dwY,dwYSize,dwXSize and added STARTF_USEPOSITION||STARTF_USESIZE to dwFlags.
但是应用程序根本无法打开.
如果我放入STARTF_USEPOSITION和STARTF_USESIZE之一,则应用程序会打开,但不会重新定位或调整大小.
But the application is not opening at all.
If i put one of STARTF_USEPOSITION and STARTF_USESIZE, the application opens but not reposition or resize.
反正有这样做吗?
{
STARTUPINFO siStartupInfo;
PROCESS_INFORMATION piProcessInfo;
memset(&siStartupInfo, 0, sizeof(siStartupInfo));
memset(&piProcessInfo, 0, sizeof(piProcessInfo));
siStartupInfo.cb = sizeof(siStartupInfo);
siStartupInfo.dwFlags = STARTF_USEPOSITION|STARTF_USESIZE;//||STARTF_USESHOWWINDOW;
siStartupInfo.wShowWindow=SW_SHOWDEFAULT;
siStartupInfo.dwX=900;
siStartupInfo.dwY=300;
siStartupInfo.dwXSize=1000;
siStartupInfo.dwYSize=1000;
if(CreateProcess("H:\\WINXP\\system32\\notepad.exe", // Application name
NULL , // Application arguments
0,
0,
FALSE,
NORMAL_PRIORITY_CLASS,
0,
0, // Working directory
&siStartupInfo,
&piProcessInfo) )
printf("Sucessful\n");
else
printf("Error");
}
推荐答案
应用程序可能会忽略STARTUPINFO
中的所有数据,或仅使用wShowWindow
.
Application may ignore all data in STARTUPINFO
, or use only wShowWindow
.
您可以尝试依次使用WaitForInputIdle
,FindWindow
和SetWindowPos
.
You can try to use WaitForInputIdle
, then FindWindow
and then SetWindowPos
.
这篇关于调整大小并重新放置使用createprocess创建的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!