How to add the "Integrity mail" menu to notepad using hooks

Source: Internet
Author: User

Lresult callback getmsgproc (INT ncode, wparam, lparam)
{
If (hc_action = ncode)
{
Char _ module [2, 256];
Getmodulefilename (null, _ module, sizeof (_ module); // obtain the module path
If (strstr (_ module, "\ notepad.exe") // check whether notepad.exe exists.
{
Lpmsg = (lpmsg) lparam; // get the message
Hmenu hmainmenu = getmenu (lpmsg-> hwnd); // obtain the menu handle of the current window
If (hmainmenu! = NULL) // If a menu exists
{
Int icount = getmenuitemcount (hmainmenu); // gets the number of items in the menu.
For (INT I = 0; I <icount; I ++)
{
Tchar sztext [255] = "";
Getmenustring (hmainmenu, I, sztext, sizeof (sztext), mf_byposition); // get the name of the menu item
If (! Strcmp (sztext, "Integrity mail") // check whether it is credit mail.
{
Break;
}
}
If (I> = icount) // load the menu if there is no credit mail menu
{
Hmenu = loadmenu (getmodulehandle ("hookhook"), makeintresource (idr_hook_menu); // load the menu
Hmenu hpopupmenu = getsubmenu (hmenu, 0); // as long as the first menu
Appendmenu (hmainmenu, mf_popup, (uint) hpopupmenu, "Integrity mail"); // Add a menu to the main menu
// Drawmenubar (lpmsg-> hwnd );
}
}

}
}

Return callnexthookex (hhook, ncode, wparam, lparam );
}

 

void sethook ()
{< br> hhook = setwindowshookex (wh_getmessage, getmsgproc, getmodulehandle ("hookhook "), 0);
}

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.