Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to End Process That Shows in Task Manager

How to End Process That Shows in Task Manager

Scheduled Pinned Locked Moved Visual Basic
helpquestionadobelinux
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mike Naughton
    wrote on last edited by
    #1

    I'm pretty new to coding to the Win32 API, so this may be a newbie question: I've got an application writen in VB6 that opens a PDF document in Adobe Acrobat Reader with the /p switch, so that it shows the print dialog window. When the user clicks "ok", I want the document to print and Acrobat Reader to close. I open Acrobat Reader using the Shell command, and I close it by sending WM_CLOSE messages to the process (following examples I found online). This all worked fine when I was using Acrobat Reader version 7, but I recently upgraded to version 9, and now I'm finding that the task manager shows AcroRd32 running even after all the windows have closed. This is a problem, since if the user tries to print a second document, a new window doesn't open and no print dialog window appears. I can get the process id, and I've tried using TerminateProcess to end it, using code: lngResult = TerminateProcess(lngProcessId, 0&) This returns a zero, which I understand means that an error has occurred, but GetLastError also returns a zero, which seems to mean no error was trapped. Can anyone help me understand what's going on, or what I'm missing here? Thanks very much for your help!

    V 1 Reply Last reply
    0
    • M Mike Naughton

      I'm pretty new to coding to the Win32 API, so this may be a newbie question: I've got an application writen in VB6 that opens a PDF document in Adobe Acrobat Reader with the /p switch, so that it shows the print dialog window. When the user clicks "ok", I want the document to print and Acrobat Reader to close. I open Acrobat Reader using the Shell command, and I close it by sending WM_CLOSE messages to the process (following examples I found online). This all worked fine when I was using Acrobat Reader version 7, but I recently upgraded to version 9, and now I'm finding that the task manager shows AcroRd32 running even after all the windows have closed. This is a problem, since if the user tries to print a second document, a new window doesn't open and no print dialog window appears. I can get the process id, and I've tried using TerminateProcess to end it, using code: lngResult = TerminateProcess(lngProcessId, 0&) This returns a zero, which I understand means that an error has occurred, but GetLastError also returns a zero, which seems to mean no error was trapped. Can anyone help me understand what's going on, or what I'm missing here? Thanks very much for your help!

      V Offline
      V Offline
      Vimalsoft Pty Ltd
      wrote on last edited by
      #2

      see this http://www.dotnetfunda.com/articles/article191.aspx[^][^] Hope it Helps

      Vuyiswa Maseko, Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers." C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.tiyaneProperties.co.za vuyiswa@its.co.za www.ITS.co.za

      M 1 Reply Last reply
      0
      • V Vimalsoft Pty Ltd

        see this http://www.dotnetfunda.com/articles/article191.aspx[^][^] Hope it Helps

        Vuyiswa Maseko, Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers." C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.tiyaneProperties.co.za vuyiswa@its.co.za www.ITS.co.za

        M Offline
        M Offline
        Mike Naughton
        wrote on last edited by
        #3

        Thanks Vuyiswa, but that solution uses dot net, and I'm using VB6. For those interested, I did find a solution: Private Const PROCESS_TERMINATE = 1 Dim lProcessHandle As Long, lResult As Long, lMyProcessID as Long lProcessHandle = OpenProcess(PROCESS_TERMINATE, True, lMyProcessID ) lResult = TerminateProcess(lProcessHandle, 0&) which seems to work. I think my problem was that I was trying to send TerminateProcess lMyProcessID instead of lProcessHandle ...

        V 1 Reply Last reply
        0
        • M Mike Naughton

          Thanks Vuyiswa, but that solution uses dot net, and I'm using VB6. For those interested, I did find a solution: Private Const PROCESS_TERMINATE = 1 Dim lProcessHandle As Long, lResult As Long, lMyProcessID as Long lProcessHandle = OpenProcess(PROCESS_TERMINATE, True, lMyProcessID ) lResult = TerminateProcess(lProcessHandle, 0&) which seems to work. I think my problem was that I was trying to send TerminateProcess lMyProcessID instead of lProcessHandle ...

          V Offline
          V Offline
          Vimalsoft Pty Ltd
          wrote on last edited by
          #4

          Welcome, Did you consider moving to .NET ?

          Vuyiswa Maseko, Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers." C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.tiyaneProperties.co.za vuyiswa@its.co.za www.ITS.co.za

          M 1 Reply Last reply
          0
          • V Vimalsoft Pty Ltd

            Welcome, Did you consider moving to .NET ?

            Vuyiswa Maseko, Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers." C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.tiyaneProperties.co.za vuyiswa@its.co.za www.ITS.co.za

            M Offline
            M Offline
            Mike Naughton
            wrote on last edited by
            #5

            I have considered it, but I am not primarily a VB programmer. I spend most of my time in the Notes/Domino web world -- LotusScript, JavaScript, HTML, and some of the rest on the iSeries (RPG). The VB apps we have are just oddball little things -- this one prints a PDF file automatically from an RPG program -- and since I'm reasonably comfortable in VB6 that's what I did it in. I've heard that moving to .NET is a big learning curve, so up to now I've stayed away from it ...

            V 1 Reply Last reply
            0
            • M Mike Naughton

              I have considered it, but I am not primarily a VB programmer. I spend most of my time in the Notes/Domino web world -- LotusScript, JavaScript, HTML, and some of the rest on the iSeries (RPG). The VB apps we have are just oddball little things -- this one prints a PDF file automatically from an RPG program -- and since I'm reasonably comfortable in VB6 that's what I did it in. I've heard that moving to .NET is a big learning curve, so up to now I've stayed away from it ...

              V Offline
              V Offline
              Vimalsoft Pty Ltd
              wrote on last edited by
              #6

              Then when you get Stuck you wont get help :)

              Vuyiswa Maseko, Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers." C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.tiyaneProperties.co.za vuyiswa@its.co.za www.ITS.co.za

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups