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?

[Webinar] Streamline your web hosting managementRegister Today

x
 
intheConnect With a Mentor Commented:
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
 
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
All Courses

From novice to tech pro — start learning today.