我目前正在嘗試製作一個強制Chrome窗口在我的第二臺顯示器上打開的應用程序,但我無法找到使用參數進行操作,現在我想知道是否可以使用Delphi強制它在第二個屏幕或特定像素上打開?這僅僅是一個適用於我自己和我的個人電腦的應用程序,所以我可以將代碼放在特定的案例中。讓Chrome在第二臺顯示器上打開?
我目前使用這段代碼,啓動應用程序
procedure TForm1.BtnClick(Sender: TObject);
begin
ExecProcess(ChromePath,'',False);
end;
function ExecProcess(ProgramName, WorkDir: string; Wait: boolean): integer;
var
StartInfo: TStartupInfo;
ProcInfo: TProcessInformation;
CreateOK: boolean;
ExitCode: integer;
dwExitCode: DWORD;
begin
ExitCode := -1;
FillChar(StartInfo, SizeOf(TStartupInfo), #0);
FillChar(ProcInfo, SizeOf(TProcessInformation), #0);
StartInfo.cb := SizeOf(TStartupInfo);
if WorkDir <> '' then
begin
CreateOK := CreateProcess(nil, Addr(ProgramName[1]), nil, Addr(WorkDir[1]),
false, CREATE_NEW_PROCESS_GROUP + NORMAL_PRIORITY_CLASS, nil, nil,
StartInfo, ProcInfo);
end
else
begin
CreateOK := CreateProcess(nil, Addr(ProgramName[1]), nil, nil, false,
CREATE_NEW_PROCESS_GROUP + NORMAL_PRIORITY_CLASS, nil, Addr(WorkDir[1]),
StartInfo, ProcInfo);
end;
{ check to see if successful }
if CreateOK then
begin
// may or may not be needed. Usually wait for child processes
if Wait then
begin
WaitForSingleObject(ProcInfo.hProcess, INFINITE);
GetExitCodeProcess(ProcInfo.hProcess, dwExitCode);
ExitCode := dwExitCode;
end;
end
else
begin
ShowMessage('Unable to run ' + ProgramName);
end;
CloseHandle(ProcInfo.hProcess);
CloseHandle(ProcInfo.hThread);
Result := ExitCode;
end;
我可以以某種方式在StartInfo.wShowWindow
也許使用的東西?
德爾福不一定是工具,我用了點。你有沒有考慮編寫JavaScript來打開一個新窗口並將其移動到你想要的位置? –
您可以嘗試['ShellExecuteEx'](http://msdn.microsoft.com/en-us/library/windows/desktop/bb762154%28v=vs.85%29.aspx)指定['SHELLEXECUTEINFO '](http://msdn.microsoft.com/en-us/library/windows/desktop/bb759784%28v=vs.85%29.aspx)。 – kobik