调整使用 createprocess 创建的应用程序的大小和位置?
我正在使用 createprocess 执行一个应用程序,比如记事本。
我需要覆盖该应用程序的默认大小和位置,因此我修改了 STARTUPINFO,并指定了 dwX、dwY、dwYSize、dwXSize 并将 STARTF_USEPOSITION||STARTF_USESIZE 添加到 dwFlags。
但该应用程序根本无法打开。
如果我放置 STARTF_USEPOSITION 和 STARTF_USESIZE 之一,应用程序将打开,但不会重新定位或调整大小。
有办法做到这一点吗?
{
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");
}
I'm executing an application say notepad, using createprocess.
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.
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.
Is there anyway to do that??
{
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");
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
应用程序可能会忽略
STARTUPINFO
中的所有数据,或仅使用wShowWindow
。您可以尝试使用
WaitForInputIdle
,然后使用FindWindow
,然后使用SetWindowPos
。Application may ignore all data in
STARTUPINFO
, or use onlywShowWindow
.You can try to use
WaitForInputIdle
, thenFindWindow
and thenSetWindowPos
.