Common commands for vc and vc operations
1. restart the computer:
ExitWindowsEx (EWX_REBOOT, 0 );
2. Shutdown:
ExitWindowsEx (EWX_SHUTDOWN, 0 );
3. logout:
ExitWindowsEx (EWX_LOGOFF, 0 );
4. screen lock:
LockWorkStation ();
5. Make the current program appear in the application bar:
ModifyStyleEx (WS_EX_APPWINDOW, WS_EX_TOOLWINDOW); // not displayed in the taskbar
6. Minimize programs to pallets;
Related API functions used: BOOL shell_policyicon (DWORD dwMessage, PNOTIFYICONDATA lpdata );
The dwMessage parameter is used to specify the actions of a tray. This is a four-byte value, as shown below:
1) NIM_ADD (0X00000000): Add a System Tray
2) NIM_MODIFY (0X00000001): System Tray Modification
3) NIM_DELETE (0X00000002): Delete the system tray
4) NIM_SETFOCUS (0X00000003): Focus on the system tray
5) NIM_SETVERSION (0X00000004): sets the version of the system tray.
The PNOTIFYICONDATA parameter is a special structure for this service. Its structure is as follows:
Typedef struct _ policyicondata
{
DWORD cbSize; // the size of the struct, in bytes.
HWND hWnd; // handle of this pallet Program
UNIT uID; // The ID allocated by the system for each icon in the tray Area
UNIT uFlags; // In short, it is a identifier
UNIT uCallbackMessage; // callback function. You need to define a message to receive a message that slides over or clicks the mouse.
HICON hIcon; // icon
TCHAR szTip [64]; // size of the prompt text
DWORD dwState; // The status of the icon
DWORD dwStateMask; // similar to the preceding
TCHAR szInfo [256]; // text displayed in the bubble notification
Union
{
UNIT uTimeout;
UNIT uVersion;
}
TCHAR szInfoTitle [64]; // the title of the bubble notification
DWORD dwInfoFlags; // modify the flag related to the bubble notification
GUID guidItem; // The GUID of the icon
HICON hBalloonIcon; // bubble notification icon
} NOTIFYICONDATA, * ppolicyicondata
Eg:
M_tnd.cbSize = sizeof (policyicondata );
M_tnd.hWnd = pWnd-> GetSafeHwnd ();
M_tnk.uID = uID;
M_tnd.hIcon = icon;
M_tnd.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
Strcpy (m_tnd.szTip, szToolTip );
// Set the tray icon
Shell_policyicon (NIM_ADD, & m_tnd );