processHandle...

Madashi, Barry, Who Ever, HELP!!!!!!!!!!!

procedure TForm1.Button10Click(Sender: TObject);
var
wnd2: hwnd;
cid: longint;
pid: dword;
i: boolean;
it: boolean;
cpid: dword;
begin
wnd2:=strtoint(edit15.text); //handle of window (this is real)
pid :=GetWindowThreadProcessID(wnd2,@cpid);
         {pid:=GetCurrentProcessId;}                      //Here
cid := OpenProcess(PROCESS_ALL_ACCESS,i,pid);
edit15.text:=inttostr(pid);
edit16.text:=inttostr(cid);
TerminateProcess(cid,0);  //NOT TERMINATING
end;

pid:=GetCurrentProcessId; if i un rem this then guess what it terminates my program thats running, so if all the rest of the code works, what am i doing wrong with               pid:=GetWindowThreadProcessID(wnd2,@cpid);

For example this returns the value 4294646219 and the real number i need is:                        4294712551 its slighty out.... as you can from the number of wasted varibles i am running out of ideas, pleaseeeeeee help :)

am i even close, cos Madashi said do this a long time ago... processHandle := OpenProcess(...,processID, ...);  TerminateProcess(processHandle, 0); thats what i am working on, without any luck.......

Craig C.
LVL 2
craig_capelAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

intheCommented:
Hi Craig,
i think you are complicating it and confusing yourself a bit :-)

try this:

procedure TForm1.Button2Click(Sender: TObject);
var
wnd2 : hwnd;
ProcessID,cpid : Cardinal;
begin
wnd2:=strtoint(edit1.text);
ProcessID := GetWindowThreadProcessID(wnd2,@cpid);
TerminateProcess(OpenProcess(PROCESS_TERMINATE,false,cpid),1);
end;

Regards Barry
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
craig_capelAuthor Commented:
I am starting to dislike you Barry, i spent the whole day trying to  figure that little problem out!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Thanks.....

Craig C.
0
intheCommented:
haha LoL
 it is the same here dont worry ,i always spend ages on something trying to figure it out, then find it to be a simple 2 lines or something :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.