Solved

How do I import from task manager into my delphi application

Posted on 2009-07-09
25
624 Views
Last Modified: 2013-12-27
I want to be able to import the image name, memory and discription from the process manager into my delphi application.
I was wondering if someone could provide a snippey as I am way behind and starting to panic.
This needs to work on xp and vista
0
Comment
Question by:SonicM3
25 Comments
 
LVL 1

Accepted Solution

by:
ccupo earned 500 total points
Comment Utility

unit Unit1;
 

interface
 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls,Tlhelp32;
 

type

  TForm1 = class(TForm)

    Button1: TButton;

    function StringTask: string;

    procedure Button1Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;
 

var

  Form1: TForm1;
 

implementation
 

{$R *.dfm}
 

function TForm1.StringTask: string;

const

  PROCESS_TERMINATE = $0001;

var

  s: string;

  ContinueLoop: BOOL;

  FSnapshotHandle: THandle;

  FProcessEntry32: TProcessEntry32;

begin

  s := '';

  FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

  FProcessEntry32.dwSize := SizeOf(FProcessEntry32);

  ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);

  while Integer(ContinueLoop) <> 0 do  begin

  s:=s+UpperCase(ExtractFileName(FProcessEntry32.szExeFile))+#13;

     ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);

  end;

  CloseHandle(FSnapshotHandle);

  Result := s;

end;
 

procedure TForm1.Button1Click(Sender: TObject);

begin

ShowMessage(StringTask);          

end;
 

end.

Open in new window

0
 

Author Comment

by:SonicM3
Comment Utility
thanks man, but anyway how instead of the taskmanager opening a big box, canit go into a memo with a scroller?

and if possible, when you highlight and click the one you want , it displays into a edit.text ?
0
 

Author Comment

by:SonicM3
Comment Utility
so its gota be like this..


data from proccess manager INCLUDING file descriot ( this is a must ).. in a nice memo with scroller. So when you scroll down and see a file description aswell as the name.. as soon as you click the name, it goes into a edit.text..

then i can do the rest mate.
0
 

Author Comment

by:SonicM3
Comment Utility
so its gota be like this..


data from proccess manager INCLUDING file description ( this is a must ).. in a nice memo with scroller. So when you scroll down and see a file description aswell as the name.. as soon as you click the name, it goes into a edit.text..

then i can do the rest mate.

sorry i didnt spell description correct, i type too fast.
0
 

Author Comment

by:SonicM3
Comment Utility
come on lads , just s above. cheers.  kinda important the data is phased inline.
0
 
LVL 36

Expert Comment

by:Geert Gruwez
Comment Utility
what do you mean with file description ?
ccupo allready gave you the filename
 s:=s+UpperCase(ExtractFileName(FProcessEntry32.szExeFile))+#13;

what is this for ?
0
 

Author Comment

by:SonicM3
Comment Utility
if you CTRL+ALT+DEL then ull see imagename, username, cpu, memory and file description. Ive seen it done on another delphi app, but no source. Im not intrested in the rest, i just want the imagename which is the process name and also the file description to be listed.

in the way above.
0
 

Author Comment

by:SonicM3
Comment Utility
i found this link that has full source. But i tried it and works great, however its too complex for what i need from it is the process part, including the descripton.

http://clk.about.com/?zi=18/1Pp&sdn=delphi&cdn=compute&tm=62&gps=142_45_1263_777&f=11&su=p284.9.336.ip_p504.1.336.ip_&tt=2&bt=1&bts=0&st=31&zu=http%3A//clk.about.com/%3Fzi%3D18/1Pp%26sdn%3Ddelphi%26cdn%3Dcompute%26tm%3D26%26gps%3D184_42_1263_777%26f%3D11%26su%3Dp284.9.336.ip_p504.1.336.ip_%26tt%3D2%26bt%3D1%26bts%3D0%26st%3D31%26zu%3Dhttp%253A//delphi.about.com/library/code/fdac_task_manager_src.zip

can someone have a look at it?

it is neat and tidy, all i want it process manager clone of the proccess's, imagename and deacription, exactly as in process manager when you CTRL+alt_del
0
 

Author Comment

by:SonicM3
Comment Utility
Ok i got it working all in list box and pharsed.

However, can someone fix my code please. at the moment it collects info from the process manager and puts it into a neat listbox. However, i dont just need the names i MUST have the description too. ( if you press ctrl+alt+del ull see under process "description" )

My code highlights the text too, and but it needs to be put into a edit.text as soon as you click on one of the process's.

Please someone help me with this.

here is the code.

( uses TLHelp32,)

((please dont correct my code withought helping me with the above ))


 procedure TForm1.Button1Click(Sender: TObject);

var

MyHandle: THandle;

Struct: TProcessEntry32;

begin

try

MyHandle:=CreateToolHelp32SnapShot(TH32CS_SNAPPROCESS, 0);

Struct.dwSize:=Sizeof(TProcessEntry32);

if Process32First(MyHandle, Struct) then

ListBox1.Items.Add(Struct.szExeFile);

while Process32Next(MyHandle, Struct) do

ListBox1.Items.Add(Struct.szExeFile);

except on exception do

ShowMessage('Error showing process list');

end

end;

Open in new window

0
 
LVL 36

Expert Comment

by:Geert Gruwez
Comment Utility
what is this for ?
0
 

Author Comment

by:SonicM3
Comment Utility
it doesnt matter what its for, its for a school project that deals with this sort of thing.
0
 
LVL 36

Expert Comment

by:Geert Gruwez
Comment Utility
a school project where you need to kill a exe ?
that doesn't sound like a project
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:SonicM3
Comment Utility
DOES IT ACTUALLY MATTER? are you going to argue or help, youve been usless.

Can someone help me please, yes it is a school project, im not going to give the exact details as ill be changing the code anyway.

UPDATE:

I have it all working, i just need someone to put the code in where it shows in my task manager "description" also.

0
 

Author Comment

by:SonicM3
Comment Utility
Omg, it doesnt matter what its for, this isnt a forum, i pay for help. I cant believe your argiung with me about my own private project.

anyway, if someone can help me out lads, would be great.
0
 
LVL 36

Expert Comment

by:Geert Gruwez
Comment Utility
it does matter. and i have my doubts about your "private" project

let me put it down as to what this looks like:

you want to get a list of programs running
you want to kill a specific one
you want to run the program with admin rights so nobody sees you killed it

why ?
maybe you want to stop a program run by the school itself, which does some monitoring
this site is not intended for behaviour like this
even if you are paying for it !

so either you come up with a good explanation or help will stop.
0
 

Author Comment

by:SonicM3
Comment Utility
the program is a removal tool for a remote admin tool, i need to find the file version so the user can select the correct one to kill at process before deleting it inside the hidden location.
The idea is to create a removal tool for a remote admin tool that the school created that only funtion is to say hi still infectect on startup, my job is to make a removal tool to disinfect reg keys the lot, i have done all this just need this final step.
0
 
LVL 36

Expert Comment

by:Geert Gruwez
Comment Utility
the asker is a person working on his "so called school project"

the question the asker is asking all lead to the following conclusion
he wants to kill a program (probably run by the school)
he wants to use admin rights
he wants to run his own program

this is what looks like replacing a running program with his own "virus" program

besides that, he does not want to give any info on the school project
and there are not other questions about this school project
there normally would be as the asker has toruble with even the simplest beginner code
0
 

Author Comment

by:SonicM3
Comment Utility
you think because i want to pull in the description its a virus, lol.
I already have the code to locate and find every process that is not what the project is about, i am looking to kill a file in the process called findme.exe and the details are called tast4 complete.
I can kill the file fine but it must match the description or task4 wont be completed.
what is the problem, why are you playing detective if your unable to answer  the question just say so.

i am not arguing here, i am trying hard to fix the problem and all you can do is pick fun at me?
sorry but there is no wild and wacky conspiracy.
0
 
LVL 36

Expert Comment

by:Geert Gruwez
Comment Utility
i will no longer answer because i find all these questions very suspicious
i can't imagine why some staff member would want a removal tool for a remote admin
quite the opposite actually, they wouldn't want it removed

this just doesn't feel right.

This is my last word on it.

Unsubscribed.
0
 

Author Comment

by:SonicM3
Comment Utility
have you even read your answer?

You wondering why I am making a removal tool for a remote admin tool (rat)
lol, maybe you should ask that same question to every single anti virus software company.
Its what it says a REMOVAL TOOL to rid a computer of a trojan horse (rat).
This is my project, what on earth are you talking about. you cant answer because you dont know, every question i have asked you have been there like a bad smell, never offering an answer.
What kind of person questions everything i am doing, I have explained to you like I was talking to my little borther to make it easy to understand.
I wont show you any respect if thats what your after sitting behind your "wait for others to asnwer then jump in at the last moment to steal points score level" because you dont deserve respect the way you have handled this question.
You need to remember who you are.
Why is it so hard to you to understand what I need, its a removal tool and you "cant amagine why someone would want this for a remote admin tool, they wouldnt want to remove it" that just sums you up dude.
if you wont help because you cant understand the question just say so, otherwise stop hassling me and answer the question, its simple all i am asking is to get the file description from the process and you are crying about it.
Dont bother to give me an answer i will wait for another user.

you sir are an idiot!
0
 
LVL 22

Expert Comment

by:8080_Diver
Comment Utility
@SonicM3,
Let me step in for a second and see if I can convey the reasoning behind the your failure to get what you consider to be reasonable answers:
  1. You have been a bit stirdent in your demand for a solution.
  2. Beert has a point in that it does matter why you want to be able to do this.  It is not unreasonable for those of us you know how to do this sort of thing to be leary of someone who seems to be something of a novice and, yet, who wants to learn how to do the sort of things that malicious applications do.  So, Geert has only acted in the same manner that most of us would have in order to keep from giving someone the means for writing, admittedly crudely sructured, malware.
  3. Your refusal to provide any reason for wanting to be able to perform the sorts of things you are asking aboout only serves to heighten suspicions, in spite of you rude responses regarding the question being asked.
  4. If this is, indeed, for a class project, then IMHO (and, I have reason to believe, Geert's as well), you bloody well need to do this yourself . . . I know that neither Geert nor I will be receiving any credits for the course you are asking us to help you pass by helping writing code for you.
  5. You are correct, you are NOT paying anyone for this requested assistance but what you do not seem to realize is that, BECAUSE you are not paying for it, a) you cannot demand it and b) you may have to justify receiving it.
  6. As for your respect, frankly I have no reason to believe that Geert or any others of us will lose sleep at night over your not respecting us.  
  7. Insulting those who might offer assistance is not a functional approach to receiving assistance . . . if you do not wish to interact with someone, just don't respond!
  8. Since you are not a company prodcing an antivirus application, why is it that you wonder why someone might be concerned about the welfare of the community at large if some anonymous ametuer programmer starts creating an app that can nuke things?  Those of us who are professional developers tend to have this thing called a conscience that leads us to be aware of the power of certain activities and the danger that can come from their being handed over to those who do not have sufficient experience to realize the implications of that power.  (And, yes, I am saying that you are inexperienced and therefore likely to do something stupid with this app . . . in the same vein that I wouldn't let your average 12 year old drive an 18-wheeler r play with automatic weapons. ;-)
  9. Finaly, you have gained a place in the list of those to whom I never expect Geert to respond and those to whom I seriously doubt any other will respond or take seriously . . . including myself.
Have a good day and I would suggest you acquire some good reading materia related to Delphi and Pascal and that you learn how to search the internet for assistance.  
0
 

Author Comment

by:SonicM3
Comment Utility
not reading that, sorry..

anyone any help on the subject pls?
0
 

Author Comment

by:SonicM3
Comment Utility
solved it myself, as these couldnt.
0
 

Author Closing Comment

by:SonicM3
Comment Utility
he never wasted by time, genuine guy.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
How to Change Interface on Cisco IOU 11 72
Delphi Form ownership 4 50
MarkLogic 1 47
tidtcpserver connection lost handle 2 41
Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now