How can I close an application using my program? - c++

I am trying to disable Norton auto protect. I don't actually want to close the program. If you click on the Norton icon it gives you the option to disable it.
I would like to write a program that clicks the button for me. I am just not sure how to go about this. I am using C++ and I have Visual Studio and Windows XP.

Do you want to close an application or disable an application (like disable java update etc)? If you are talking about closing an application using your program, you can use "TerminateProcess()".
If you are talking about disabling application, share with us particular use-case exactly what do you want to achieve?

Related

Override Close Box on Windows 10 Universal Apps UWP

I'm trying to prevent the app from being closed by clicking the Close box on the App Window.
For example, having a text editor with unsaved changes, upon pressing Close Box, I would first display, "Do you want to save changes before exiting?"
How can I detect app wanting to close and prevent that from happening?
I'm using C++, and this needs to be for Windows 10 Universal Apps UWP.
I already know how to do this for Win32.
The comments are correct. There is currently no way for a regular Store app to do this.
However, with the Creators Update (and corresponding SDK) we have included a preview API that you can now check out for this functionality:
The Windows.UI.Core.Preview.SystemNavigationManagerPreview class provides a CloseRequested event that an app can mark as handled. For the event to work the app will need to declare the restricted 'confirmAppClose' capability per:
https://learn.microsoft.com/en-us/windows/uwp/packaging/app-capability-declarations
Please let us know your feedback.
Thanks,
Stefan Wick - Windows Developer Platform

Prevent a Windows app from stealing the focus

I have created a windows application in C++ and I want to make so whenever I run it, it doesn't steal focus from whichever window is currently focused(or maybe steal the focus and give it back right away). I'm not creating any window so i'm not sure how to change the window style, my program runs in the background.
I couldn't find any answer that worked for C++, is there any way I can do this?
When you start your application by clicking on the EXE or shortcut, Windows Explorer takes focus, not your app. The only way to start your app and not let Windows Explorer take focus is to start your program when Windows starts, via registry key.
Make sure you use the extended style WS_EX_NOACTIVATE when using CreateWindowEx().
See the Microsoft Docs for CreateWindowEx.

how to create a Window WIN32?

I just wondering how Windows create this window?
I mean what styles applied to that window, I just want these styles on my project.
As info I use MS Visual C++ 2008.
Thanks
There's no easy way! There's no public API for using "the Windows 8 style", or the style of any other release. You'll just have to replicate it by hand, comparing it pixel-for-pixel against a screenshot. Then update your application with the next release of Windows!
Because they change the metrics of these sorts of dialogs with each release, they can't produce a public library for "system-themed dialogs", because Microsoft would then be unable to change the design for fear of breaking someone's application that maybe uses a bit too much text, for example.

Make a custom taskbar and shell area for my own custom explorer program?

What I would like to do is to create my own custom explorer instead of windows explorer.exe but I would like to be able to create my own taskbar with the active programs and the shell area with the icons as well.
I looked online for a day and can't find anything out about. My main language is c++ and I am very familiar with the windows api calls, resources, and even extracting resources from dlls as well.
I just don't know how to start with the task bar.
Like I said I want to be able to make my own explorer program for windows with the taskbar and all.
I just don't know where to look or start.
Thank you all :)

Portable way to hide console window in GLUT application?

Hey, I'm creating a little GLUT application and need help with hiding/removing the console window.
I am developing on windows and I already know of the various methods to hide the console window on a windows system, however is there no portable method of hiding it?
Thanks...
You don't really want to "hide" the console window. What you want is to configure your compiler to generate a "Windows application" instead of a "Console application". That will tell windows to never create a console for your application. You'll need to consult your compiler's documentation to figure out how to do that. For Visual Studio, it is a step on one of the wizards.
There isn't really a good way to control the console inside of a console application. The console is designed so that the application knows nothing about it. While it is possible, as you said, it's not very portable or clean.
The correct approach if you need fine-grained control over the "console" is to implement your own window which provides a text output area where you can print things. Then you can do pretty much anything with your "console" because it isn't really a console, it's just another window owned and operated by your application.