CreateProcess StartupInfo 改變外部程式視窗的起始位置和大小
var
zAppName:array[0..512] of char;
zCurDir:array[0..255] of char;
WorkDir:String;
StartupInfo:TStartupInfo;
ProcessInfo:TProcessInformation;
FileName:String;
begin
FileName:='C:/Program Files/Borland/Delphi7/Projects/project12.exe';
StrPCopy(zAppName,FileName);
GetDir(0,WorkDir);
StrPCopy(zCurDir,WorkDir);
FillChar(StartupInfo,Sizeof(StartupInfo),#0);
StartupInfo.cb := Sizeof(StartupInfo);
StartupInfo.dwX := 0;
StartupInfo.dwY := 0;
StartupInfo.dwXSize := 800;
StartupInfo.dwYSize := 600;
StartupInfo.dwFlags := STARTF_USESIZE or STARTF_USEPOSITION ;
StartupInfo.wShowWindow := SW_SHOWDEFAULT ;
CreateProcess(nil,zAppName,nil,nil,false,0,nil,nil,StartupInfo,ProcessInfo);
end;
如果建立的程序不能指定位置和窗體大小,請檢查 FileName:='C:/Program Files/Borland/Delphi7/Projects/project12.exe'主窗體的引數設定,其WindowsState應為wsNormal,Position應該為poDefault,
這樣CreateProcess才能按照StartupInfo中設定的值來設定啟動程式的位置和大小。