|
Seems to work with one exception. I get a flicker since it instantly lose its focus and then regain it back....
sdancer75
|
|
|
|
|
One last thing. The EnableWindow(xxxx) do the mess in my situation. If I dont use this function I have to process the paint messages from the child window. In this case I think that
WaitForMultipleObjects will do the job in the XP case. Do you agree with this guess ?
.... or better i will give it a try right now.
sdancer75
|
|
|
|
|
No, WFMO is the same as WFSO (just waiting for more than one object; however I don't see any additional one in your problem description).
The usual way is move waiting in a worker thread to not block the main UI thread.
|
|
|
|
|
When the external update process should also update the executable of your main application, that must be terminated before the new exe file can be copyied. So there is no need to get the focus back.
A typical sequence for such a process:
- Ask the user if the update should be installed
- Perform closing tasks that are time consuming or require user interaction like closing open documents
- Start the update process
- Terminate your application
- The update process should check if there is a running instance of your application (after a short wait time) and terminate with an error if so
- The update process might restart your application
In another post you mentioned that you are using WaitForSingleObject to wait for the update process to be terminated. If you call that from within your main thread, your application's message loop is blocked so that paint events are not processed.
If you don't want to update the executable itself and must wait for the external process to be finished start the process from within a worker thread where you can call WaitForSingleObject without blocking the message loop. Use a global state variable indicating that the update is executing to disallow specific tasks of your application or just show a modal dialog that is closed automatically when the update has finished.
|
|
|
|
|
Quote: When the external update process should also update the executable of your main application, that must be terminated before the new exe file can be copyied. So there is no need to get the focus back.
I have managed this kind of problems with success so, dont bother with that.
Quote: In another post you mentioned that you are using WaitForSingleObject to wait for the update process to be terminated. If you call that from within your main thread, your application's message loop is blocked so that paint events are not processed.
Thats correct. Windows Vista/Win7/Win8 does not have problems with paint events but XP they have. For that reason I want to disable the parent to avoid such kind of problems.
Quote: If you don't want to update the executable itself and must wait for the external process to be finished start the process from within a worker thread where you can call WaitForSingleObject without blocking the message loop. Use a global state variable indicating that the update is executing to disallow specific tasks of your application or just show a modal dialog that is closed automatically when the update has finished.
I update the executables too, but I dont have problems with that. If you download the sample code, you will understand the focus problem i currently have.
sdancer75
|
|
|
|
|
My intention was to show you a solution that differs from your current implementation and pointing to the fact that you block the message loop.
You must not call WaitForSingleObject from within your main thread to ensure that the window is repainted (e.g. when moving another window over the application window). That will solve the problem of paint corruption and might also solve your other problems.
Overall I think I must shout:
Don't use WaitForSingleObject from within your main GUI thread; especially with long wait times!
I (like most others here) will not download a complete project and build it. Especially in this case where it must be tested with XP too.
|
|
|
|
|
Thanks for your time. Do you suggest to use WaitForMultipleObjects instead ?
sdancer75
|
|
|
|
|
No. That is similar (it can just wait for more events).
Don't use any blocking wait (or more general: any function that may block for long intervals) from within the main GUI thread. As already suggested you might use a worker thread.
|
|
|
|
|
The worker thread does not lock the main app as long as its active. I dont want this. I just want a modal like behaviour and not floating windows all around the desktop.
sdancer75
|
|
|
|
|
You can disable your app window and/or show a modal dialog while the worker thread is active and re-enable when it finishes. So the message loop is not blocked and repainting is ensured while the app itself is blocked.
What do you mean by floating windows? There is no additional window.
|
|
|
|
|
Quote: You can disable your app window and/or show a modal dialog while the worker thread is active and re-enable when it finishes.
You mean a dummy dialog just to block to main app ?
Quote: What do you mean by floating windows? There is no additional window.
I mean the two windows that will be active at the same time (main and child) and user will have the ability to work with the both of them.
sdancer75
|
|
|
|
|
sdancer75 wrote: You mean a dummy dialog just to block to main app ?
Yes. Or just disable the main window. The dialog can show something like "Please wait until the update is installed".
sdancer75 wrote: I mean the two windows that will be active at the same time (main and child) and user will have the ability to work with the both of them. When the app is blocked by disabling or a dialog it can't be moved by the user (the dialog may be moved). So when not using a dialog it is the same behaviour as with your current solution.
|
|
|
|
|
Finally I used MsgWaitForMultipleObjects with message process loop. I avoid to use EnableWindow() function at all.
It seems to work fine under Win7. I will take a copy to my work tommorow to test it under XP for paint corruption.
sdancer75
|
|
|
|
|
I need the parent window -which is the main app- to be disabled (like a modal dialog box behaviour) until the new app -update application- will finish its job.
Did you try to hide or minimize the "parent window" instead?
|
|
|
|
|
Yes this way it works but I dont want to minimize the parent window. I need a modal like behaviour.
sdancer75
|
|
|
|
|
Hi Folks,
I have created a sample console app (windows universal) using VS2015. If I call the method QueryDosDevice(), it results into ERROR_ACCESS_DENIED error. I am deploying this app on Windows 10. Interestingly I can call APIs from ntdll. But seems like it gives access denied error if I try to call APIs from kernel32.
Are there are access (perhaps for volume management APIs) restrictions introduced for universal apps? If yes, Is there any way around it?
-- Vikram
|
|
|
|
|
|
I went thr the alternative API's, but seems that they are not available with VS2012. Do we have any alternative legacy API which I can probably use?
|
|
|
|
|
Unfortunately, no. The store app platform is very limited for security reasons.
Perhaps you could explain what you're trying to achieve and someone could suggest a workaround.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Is there any kernel equivalent of this method?
I can see IoVolumeDeviceToDosName(), not sure. if this is correct one.
|
|
|
|
|
Dear Friends,
I have requirement to disable UAC prompt through programmatically. Please anyone help me on this.
Thanks,
S Shanmuga Raja
|
|
|
|
|
No. The UAC prompt is there to protect the owner of the PC.
|
|
|
|
|
That is not possible for the current login session because it would defeat the purpose of UAC.
You can change the setting using the registry but that requires a reboot to become active (see Enable or Disable UAC From the Windows Command Line[^]; it is for the command line but shows the registry settings to be changed).
|
|
|
|
|
whether its possible to assign administrator right to my application though programmatically. So that I can set value 0 or 1 to EnableLUA in registry.
|
|
|
|
|
Assigning administrator rights to an application requires administrative privileges. So while it does not have these, you can't change it. And you can not elevate the privileges of a running process.
You can use a manifest to specify that your application should run elevated, use the "runas" command or start other applications elevated from within your program. But in all these cases there will be a UAC prompt.
UAC is there for a reason. It is a security feature. The user decides which level of security should be used. An application can not bypass these settings.
|
|
|
|