我正在使用提供给我的程序,它将运行一个进程,但我希望该进程在后台运行而不显示窗口.电话是
ExecProcess(ProgPath, '', False);
Run Code Online (Sandbox Code Playgroud)
而且功能是
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 or NORMAL_PRIORITY_CLASS, nil, nil,
StartInfo, ProcInfo);
end
else
begin
CreateOK := CreateProcess(nil, Addr(ProgramName[1]), nil, nil, false,
CREATE_NEW_PROCESS_GROUP or NORMAL_PRIORITY_CLASS, nil, Addr(WorkDir[1]),
StartInfo, ProcInfo);
end;
{ check to see if successful …Run Code Online (Sandbox Code Playgroud) 我正在尝试制作一个强制Chrome窗口在我的第二台显示器上打开的应用程序,但我无论如何都找不到使用参数来做,现在我想知道我是否可以某种方式使用Delphi强制它打开第二个屏幕还是特定的像素?这只是我自己和我的电脑的应用程序,所以我可以根据我的情况专门设置代码.
我目前正在使用这段代码来启动应用程序
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 …Run Code Online (Sandbox Code Playgroud) 我在使用指定的initialdir启动OpenDialog窗口时遇到问题.我现在拥有的是什么
procedure TForm1.fileMenuLoadClick(Sender: TObject);
begin
SetCurrentDir(StartDir);
SetCurrentDir('Cases');
OpenDialog.Filename := '';
OpenDialog.InitialDir := GetCurrentDir;
OpenDialog.Filter := 'Sparfiler (.dat)|*.dat';
// -------------------------------
if OpenDialog.Execute then
begin
GeometryClear;
DerobModel.Filename := OpenDialog.Filename;
DerobModel.Open;
pressed := True;
SetCurrentDir('../');
DerobModel.HouseProperties.StringValue['CaseDir'] := GetCurrentDir;
DerobModel.HouseProperties.StringValue['StartDir'] := StartDir;
SetCurrentDir(StartDir);
UpdateGeometryPanel;
mainUpdateComboBox;
UpdatePropertiesPanel;
UpdateEnergyPanel;
UpdateAbsorption;
UpdateClimatePanel;
UpdateClimate;
mainHide;
Geometry.IsSelected := True;
GeometryPanel.Visible := True;
TreeView1.Enabled := True;
TreeView1.HitTest := True;
DerobModel.HouseProperties.BoolValue['GlazeChange'] := False;
end;
Run Code Online (Sandbox Code Playgroud)
运行此代码时,它会一直打开我打开的最后一个文件的文件夹.我读到解决方案是清除OpenDialog的FileName属性,但它不起作用.然而有趣的是,它正在处理来自我的应用程序的先前版本的代码.
procedure TForm1.fileMenuLoadClick(Sender: TObject);
begin
SetCurrentDir(StartDir);
SetCurrentDir('Cases');
OpenDialog.Filename := '';
OpenDialog.InitialDir := GetCurrentDir;
OpenDialog.Filter := 'Sparfiler (.dat)|*.dat'; …Run Code Online (Sandbox Code Playgroud) 我正在尝试对某些值进行多次检查,但我无法让它工作.
if DerobModel.HouseProperties.IntValue['VolumeNorth'] = 1 then
ivol[2] := 1;
else
if DerobModel.HouseProperties.IntValue['VolumeEast'] = 1 then
ivol[2] := 1;
end
else
if DerobModel.HouseProperties.IntValue['VolumeWest'] = 1 then
ivol[2]:=1;
end;
Run Code Online (Sandbox Code Playgroud)
我想检查"VolumeNorth"是否为1,然后指数ivol [2]将为1,否则如果East为1,则ivol [2]应为1,如果不是,则检查West和南也是如此(这还不在代码中).如果它们都不是1那么ivol就不会发生任何事情[2].我如何让它工作?
谢谢!