program SizeFFWindow1;
{$APPTYPE Console}
uses
SysUtils,
Windows;
var m_Window: HWND;
function EnumWindowsProc(Wnd:HWND; lParam:LPARAM): boolean;
var processID: DWORD;
begin
Result := true;
processID := 1;
GetWindowThreadProcessId(Wnd, @processID);
writeln('PID = '+Inttohex(processID,8)+' Wnd = '+Inttohex(Wnd,8)+
' Look for '+Inttohex(lParam,8));
if processId = lParam then
begin
m_Window := Wnd;
Result := false;
writeln('------ Matched -----');
end;
end;
var
sProcessInfo: PROCESS_INFORMATION;
sStartupInfo: STARTUPINFO;
szCommandLine: PChar;
dw: DWORD;
begin
//start ff
ZeroMemory(@sStartupInfo,sizeof(STARTUPINFO));
ZeroMemory(@sProcessInfo,sizeof(PROCESS_INFORMATION));
sStartupInfo.cb := sizeof( STARTUPINFO);
szCommandLine := PChar('"H:\Program Files\Mozilla Firefox\firefox.exe"');
//char szCommandLine[260] = {"C:\\windows\\notepad.exe"};
CreateProcess(nil, szCommandLine, nil, nil, false, {CREATE_NO_WINDOW or}
NORMAL_PRIORITY_CLASS, 0, 0, sStartupInfo, sProcessInfo);
dw := WaitForInputIdle(sProcessInfo.hProcess, 10000);
Sleep(2000);
m_Window := 0;
EnumWindows(@EnumWindowsProc, sProcessInfo.dwProcessId);
if (m_Window <> 0) then
MoveWindow(m_Window, 100, 100, 800, 600, TRUE);
writeln('Press Enter');
Readln;
end.
|