DELPHI gets process handle through window handle or window caption

Source: Internet
Author: User

http://blog.csdn.net/diligentcatrich/article/details/6250204DELPHI gets process handle through window handle or window captionTags: delphiaccess2011-03-15 11:02 1205 people read comments (0) favorite reports Classification:Delphi (251)

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

DELPHI through window handle or window caption get process handle May 08, 2009 Friday 10:15
Procedure Tform1.button1click (Sender:tobject);
Var
Hwindow:hwnd; {form Handle}
Dwprocessid:dword; {Process ID}
Hprocess:thandle; {Process Handle}
Begin
{Gets the handle of the form according to the caption}
Hwindow: = FindWindow (nil, ' title ');

{Get process ID through form handle}
GetWindowThreadProcessId (Hwindow, Dwprocessid);

{Get process handle through process ID}
Hprocess: = OpenProcess (Process_all_access, False, Dwprocessid);

{End the process}
TerminateProcess (hprocess, 0);
End

DELPHI gets process handle through window handle or window caption

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.