CreateProcess StartupInfo 改变外部程序窗口的起始位置和大小不起作用,怎么解决

时光小偷的老巢 2019-03-31 10:57:05
按照MSDN中的说法,只要指定STARTUPINFO中的dwX,dwY,dwXSize,dwYSize四个变量的值,然后将
dwFlags = STARTF_USESHOWWINDOW || STARTF_USESIZE || STARTF_USEPOSITION进行如此设置,即可为新打开的应用程序的位置与大小。但是运行结果并没有起到任何作用,麻烦各位大佬帮小弟看看这个问题怎么解决,谢谢。

具体代码如下:

PROCESS_INFORMATION pi;
STARTUPINFO si = { sizeof(si) };
si.dwFlags = STARTF_USESHOWWINDOW || STARTF_USESIZE || STARTF_USEPOSITION;
si.wShowWindow = SW_SHOWDEFAULT;
si.dwX = 0;
si.dwY = 0;
si.dwXSize = 800;
si.dwYSize = 600;

char szApplicationName[] = "D:\\爱奇艺\\IQIYI Video\\LStyle\\6.7.82.6548\\QyClient.exe";
char szCommandLine[] = "QyClient.exe";

BOOL bRet = CreateProcess(szApplicationName, szCommandLine, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi);
...全文
257 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
5-cOin 2019-06-02
  • 打赏
  • 举报
回复
如果要启动的程序不读取STARTUPINFO参数当然就不会有用
可以启动后用SetWindowPos来设置
schlafenhamster 2019-03-31
  • 打赏
  • 举报
回复
dwX
Ignored unless dwFlags specifies STARTF_USEPOSITION. Specifies the x offset, in pixels, of the upper left corner of a window if a new window is created. The offset is from the upper left corner of the screen. For GUI processes, the specified position is used the first time the new process calls CreateWindow to create an overlapped window if the x parameter of CreateWindow is CW_USEDEFAULT.
dwY
Ignored unless dwFlags specifies STARTF_USEPOSITION. Specifies the y offset, in pixels, of the upper left corner of a window if a new window is created. The offset is from the upper left corner of the screen. For GUI processes, the specified position is used the first time the new process calls CreateWindow to create an overlapped window if the y parameter of CreateWindow is CW_USEDEFAULT.
zgl7903 2019-03-31
  • 打赏
  • 举报
回复
用位或|, 而不是逻辑或 || si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESIZE | STARTF_USEPOSITION; 如果不行 就试试 Findwindow SetWindowPos
  • 打赏
  • 举报
回复
引用 1 楼 schlafenhamster 的回复:
dwX
Ignored unless dwFlags specifies STARTF_USEPOSITION. Specifies the x offset, in pixels, of the upper left corner of a window if a new window is created. The offset is from the upper left corner of the screen. For GUI processes, the specified position is used the first time the new process calls CreateWindow to create an overlapped window if the x parameter of CreateWindow is CW_USEDEFAULT.
dwY
Ignored unless dwFlags specifies STARTF_USEPOSITION. Specifies the y offset, in pixels, of the upper left corner of a window if a new window is created. The offset is from the upper left corner of the screen. For GUI processes, the specified position is used the first time the new process calls CreateWindow to create an overlapped window if the y parameter of CreateWindow is CW_USEDEFAULT.

想请教一个问题: 如果创建的进程不能指定位置和窗体大小,请检查 FileName:='C:/Program Files/Borland/Delphi7/Projects/project12.exe'主窗体的参数设置,其WindowsState应为wsNormal,Position应该为poDefault, 请问如何查看主窗体的参数设置,在哪里能看到WindowsState呢?
schlafenhamster 2019-03-31
  • 打赏
  • 举报
回复
再 FindWindow
MoveWindow

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧