How to get url of hyperlink in outlook 2019 when open the hyperlink. Using setwindowshookEx with WH_CALLWNDPROCRET OR WH_CALLWNDPROC

mohamad fraihat 1 Reputation point
2021-05-21T23:26:13.817+00:00

The below is part of the code in callback of WH_CALLWNDPROCRET OR WH_CALLWNDPROC as per my under standing about RichEdit control but I never catch the WM_NOTIFY, but EM_GETTEXTEX it is work fine and return the mail subject (caption of RichEdit). thes RichEdit class name is RichEdit20WPT.

if (cwprStruct->message == WM_NOTIFY)
    {
        writetofile("WM_NOTIFY RetProc:", f1);
        switch (((LPNMHDR)cwprStruct->lParam)->code)
        {
        case EN_LINK:
            writetofile("EN_LINK:", f1);
            break;
        case NM_CLICK:
            writetofile("NM_CLICK:", f1);
            break;
        case NM_RETURN:
            writetofile("NM_RETURN:", f1);
            break;
        case NM_RCLICK:
            writetofile("NM_RCLICK:", f1);
            break;
        case NM_SETFOCUS:
            writetofile("NM_SETFOCUS:", f1);
            break;
        }
        writetofile(to_string(((LPNMHDR)cwprStruct-lParam)->code), f1);
    }
    if (cwprStruct->message == EM_GETTEXTEX)
    {
        isURL = true;
        writetofile("EM_GETTEXTEX:", f1);
        number = GetClassName(cwprStruct->hwnd, clsName_v, 256);
        writetofile(clsName_v, number, f1);// return RichEdit20WPT

        writetofile("Subject:", f1);
        if (cwprStruct->lParam)
        {
            size_t   i;
            char* subject = (char*)malloc(BUFFER_SIZE);
            wcstombs_s(&i, subject, (size_t)BUFFER_SIZE, (LPWSTR)cwprStruct->lParam, (size_t)BUFFER_SIZE);
            writetofile(subject, i - 1, f1);
        }
    }
Windows development Windows API - Win32
Developer technologies C++
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.