Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 153
  • Last Modified:

Current Apps running...

I need to know a procedure or routine that tells you what apps are running under windows 95. I'm writing an app which should say which apps are currently being executed in the win95 operating system. I know there is EnumWindows but I don't know how to use it. Please Help!
0
kh5395
Asked:
kh5395
1 Solution
 
interCommented:
Hi,

The following enumaretes more than you want, you can restrict or losen the criteria to display the memory contents on even window basis. Just change the IF statement in the EnumWindowsProc. To compile , create a new unit, add A button, A ListBox, assign OnClick event of button to the following code(Button1Click) then run.

var
  S : TStringList;

function EnumWindowsProc(hwnd : HWND ;lParam : longint):boolean;stdcall;
var
  wn : array[0..255] of char;
  pid: THandle;
  w : string;
begin
  if hwnd <> 0 then
  begin
    GetWindowThreadProcessId(hwnd, @pid);
    // filter out if this is our application window
    // and all child windows
    if (pid <> GetCurrentProcessId) and (GetParent(hwnd)= 0) then
    begin
      // get the caption
      // or use the commented IF to get application names
      if GetWindowText(hwnd, wn,sizeof(wn)) <> 0 then
//    if GetModuleFileName(GetWindowLong(hwnd,GWL_HINSTANCE),wn,sizeof(wn)) <> 0 then
      begin{}
        w:= Format('%6d ',[pid])+StrPas(wn);
        S.Add(w);
      end;{}
   end;
    result := true;
  end else result := false;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  try
   S := TStringList.Create;
   S.Sorted := true;
   S.Duplicates := dupIgnore;
   ListBox1.Items.Clear;
   S.Clear;
   EnumWindows(@EnumWindowsProc,0);
   ListBox1.Items.AddStrings(S);
  finally
    S.Free;
  end;
end;

Bye
Igor

0
 
kh5395Author Commented:
Thanks for the help!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now