VC/MFC program turn off other software, change window class

Source: Internet
Author: User

Process:

1. Get the window of the target program HWND hwnd

HWND hwnd =:: Findwindowa (_t ("Softwareclassname"), NULL); Get windows that require software

2. int ret =:: SendMessageA (HWnd, wm_close,0,0); //Close Software

3. WinExec (D:\\foxit reader.exe,sw_showmaximized); Open Software

About FindWindow () there are two parameters the first one is the window class name, the second is the window name. Use only one of them is sufficient, and the other parameter writes NULL

For the switch to write the software can customize the window class name step as follows:

1. In the RC file of the window, add

CLASS "Softwareclassname"

2. Add the following lines of code to register the window class before the window is created

/////////////////////////////////////////////////////////
WNDCLASS WC;

Get the info for this class.
#32770 is the default class name for dialogs boxes.
:: GetClassInfo (AfxGetInstanceHandle (), _t ("#32770"), &WC);

Change the name of the class.
Wc.lpszclassname = _t ("Softwareclassname"); Please note again here, be sure to keep the same class name as the RC resource file!

Register This class so, MFC can use it.
BOOL Ret=afxregisterclass (&WC);

/////////////////////////////////////////////////////////

For the switch others write software can be obtained by the software name steps are as follows:

Download Microsoft software Spy + + Get the currently open software window name and class name, such as the Classfoxitreader Reader for Window name, window class name.

Software: Http://pan.baidu.com/s/1kV8frCV

VC/MFC program turn off other software, change window class

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.