我在公司的软件里的一个地方调用了windows的计算器。我碰到两个问题,不知道该找什么函数解决。
第一。打开时计算器的位置总是不能固定,怎么样固定在屏幕中间或指定位置。第二。关闭程序不能一起关闭计算器。怎么解决?
大家帮忙啊>。>急

解决方案 »

  1.   

    第一个问题,你可以看看winexec的参数
    第二个问题,在你关闭程序的时候,取一下当前计算机的进程列表,然后关闭计数器进程,然后关闭程序
    关闭进程的程序,你可以参考一下下面的程序还有,你的分太少了
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, TLHelp32, Controls, Forms, Dialogs,
      StdCtrls;type
      TProcessInfo = record
        ExeFile: string;
        ProcessId: DWORD;
      end;
      ProcessInfo = ^TProcessInfo;  TForm1 = class(TForm)
        ListBox1: TListBox;
        Button1: TButton;
        Button2: TButton;
        procedure ProcessList(var pList: TList);
        procedure My_RunFileScan(ListboxRunFile: TListBox);
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
        Current: TList;
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}
    procedure TForm1.ProcessList(var pList: TList);
    var
      p: ProcessInfo;
      ok: Bool;
      ProcessListHandle: THandle;
      ProcessStruct: TProcessEntry32;
    begin
      PList := TList.Create;
      PList.Clear;
      ProcessListHandle := CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS, 0);
      ProcessStruct.dwSize := Sizeof(ProcessStruct);
      ok := Process32First(ProcessListHandle, ProcessStruct);
      while Integer(ok) <> 0 do
        begin
          new(p);
          p.ExeFile := ProcessStruct.szExeFile;
          p.ProcessID := ProcessStruct.th32ProcessID;
          PList.Add(p);
          ok := Process32Next(ProcessListHandle, ProcessStruct);
        end;
    end;procedure TForm1.My_RunFileScan(ListboxRunFile: TListBox);
    var
      i: Integer;
      p: PRocessInfo;
    begin
      current := TList.Create;
      Current.Clear;
      ListboxRunFile.Clear;
      ProcessList(Current);
      for i := 0 to Current.Count - 1 do
        begin
          new(p);
          p := Current.Items[i];
          ListboxRunFile.Items.Add(p.ExeFile);
        end;
    end;procedure TForm1.Button1Click(Sender: TObject);
    var
      h: THandle;
      a: DWORD;
      p: PRocessInfo;
    begin
      if ListBox1.ItemIndex >= 0 then
        begin
          p := Current.Items[ListBox1.ItemIndex];
          h := openProcess(Process_All_Access, true, p.ProcessID);
          GetExitCodeProcess(h, a);      if Integer(TerminateProcess(h, a)) <> 0 then
            begin
              My_RunFileScan(ListBox1);
            end;
        end
      else
        Application.MessageBox('&Ccedil;&euml;&Iuml;&Egrave;&Ntilde;&iexcl;&Ocirc;&ntilde;&Ograve;&raquo;&cedil;&ouml;&frac12;&oslash;&sup3;&Igrave;!', '&ordm;&Uacute;&para;&acute;', MB_ICONERROR + MB_OK);
    end;
    procedure TForm1.Button2Click(Sender: TObject);
    begin
      My_RunFileScan(ListBox1);
    end;end.
      

  2.   

    winexec里有用来控制调用程序的屏幕位置的参数吗?没有吧。我不知道。可以指教一下吗?