Opening Disk Defragmenter from inside a WIN32 app [modified]
-
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
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()
orCreateProcessWithLogonW()
?"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
-
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
Use ShellExecuteEx()[^], then you can use WaitForSingleObject()[^] on the hProcess member of SHELLEXECUTEINFO[^] to get notified when the process exits.
-
Use ShellExecuteEx()[^], then you can use WaitForSingleObject()[^] on the hProcess member of SHELLEXECUTEINFO[^] to get notified when the process exits.