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. C / C++ / MFC
  4. Opening Disk Defragmenter from inside a WIN32 app [modified]

Opening Disk Defragmenter from inside a WIN32 app [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
4 Posts 3 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.
  • D Offline
    D Offline
    dipuks
    wrote on last edited by
    #1

    Hey If i am right CreateProcess() function can't be used in this case, as Disk Defragmenter needs Admin privilages to open. Please explain me how to do this. Thanks in advance.

    modified on Wednesday, March 2, 2011 6:36 PM

    D N 2 Replies Last reply
    0
    • D dipuks

      Hey If i am right CreateProcess() function can't be used in this case, as Disk Defragmenter needs Admin privilages to open. Please explain me how to do this. Thanks in advance.

      modified on Wednesday, March 2, 2011 6:36 PM

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      dipuks wrote:

      Now i want to disable the app controls when the Disk Defragmenter is OPEN and then re-enable the app controls when Disk Defragmenter is CLOSED.

      How to do this?

      Do you have a handle to the window?

      dipuks wrote:

      I am using ShellExecute function to open the Disk Defragmenter. I can know when the Disk Defragmenter is OPENED, but not when it's CLOSED. Is that true?

      Look at the PROCESS_INFORMATION structure. Monitoring those handles or IDs should provide you this information.

      dipuks wrote:

      If i am right CreateProcess() function can't be used in this case, as Disk Defragmenter needs Admin privilages to open.

      Can you use CreateProcessAsUser() or CreateProcessWithLogonW()?

      "One man's wage rise is another man's price increase." - Harold Wilson

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      "Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather

      1 Reply Last reply
      0
      • D dipuks

        Hey If i am right CreateProcess() function can't be used in this case, as Disk Defragmenter needs Admin privilages to open. Please explain me how to do this. Thanks in advance.

        modified on Wednesday, March 2, 2011 6:36 PM

        N Offline
        N Offline
        Niklas L
        wrote on last edited by
        #3

        Use ShellExecuteEx()[^], then you can use WaitForSingleObject()[^] on the hProcess member of SHELLEXECUTEINFO[^] to get notified when the process exits.

        home

        D 1 Reply Last reply
        0
        • N Niklas L

          Use ShellExecuteEx()[^], then you can use WaitForSingleObject()[^] on the hProcess member of SHELLEXECUTEINFO[^] to get notified when the process exits.

          home

          D Offline
          D Offline
          dipuks
          wrote on last edited by
          #4

          Thank you guys.....i Did it!

          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