Results 1 to 3 of 3

Thread: Terminate A Process with Process ID

  1. #1
    senthilk
    Guest

    Smile

    I want to terminate a process by its process id. I have tried with openprocess() & terminateprocess(). But its not working. I am giving u the code which i tried.

    Dim processid As Long
    Dim processhandle As Long
    Dim lExitCode As Long
    processid = Shell("C:\winnt\system32\notepad.exe", vbMinimizedFocus)

    processhandle = OpenProcess(PROCESS_ALL_ACCESS, 0&, processid)
    GetExitCodeProcess processhandle, lExitCode
    TerminateProcess processhandle, lExitCode

    Its not working bcos terminateprocess is taking processhandle(it becomes 0 as soon as it opens notepad.exe) , but i want to terminate the notepad.exe . How to do that? Can u help me in this regard?

  2. #2
    Hyperactive Member tumblingdown's Avatar
    Join Date
    Mar 2000
    Posts
    362
    Why don't you send message a WM_CLOSE to the notepad


    td.
    "One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig


    [email protected]

    "but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.

  3. #3
    senthilk
    Guest
    Hi tumblingdown,
    Its working fine...

    Thanx a lot.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width