Advertisement
Combreal

wKillRing.cpp

Feb 10th, 2019
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 31.35 KB | None | 0 0
  1. #include <windows.h>
  2. #include <dwmapi.h>
  3. #include <iostream>
  4. #include <fstream>
  5. #include <sstream>
  6. #include <string>
  7. #include "resource.h"
  8. #include <commctrl.h>
  9. #include <vector>
  10. #include <algorithm>
  11. #pragma warning(disable : 4800)
  12. #pragma comment( lib, "comctl32.lib" )
  13.  
  14. int pipeCounter = -1, procInfCounter = -1;
  15. std::vector<HANDLE>pipeHandles;
  16. std::vector<PROCESS_INFORMATION>procInf;
  17. std::vector<std::string>killRing;
  18. bool showWindowB = false;
  19. bool showWindowC = false;
  20. bool showWindowD = false;
  21. bool showWindowE = false;
  22. bool startWithWindows = false;
  23. bool copyStarted = false;
  24. char wKillRingPath[MAX_PATH];
  25. char ccommand[4096];
  26. std::string exePath, exeFullPath, confPath, commandResult, command;
  27. int counter = 0, killRingPos = -1;
  28. HWND hWindowa, hWindowb, hWindowc, hWindowd, hWindowe, hButtonA1, hTextA1, hTextA2, hTextA3, hTextB1, hTextB2, hTextB3, hTextC1, hTextC2, hTextC3, hTextB;
  29. HWND hHotKeyA1, hHotKeyA2, hButtonPasteA, hButtonPasteB, hButtonPasteC, hButtonPasteD;
  30. HWND hwndEditWA, hwndButtonWA, hwndEditWB, hwndButtonWB, hwndEditWC, hwndButtonWC, hwndEditWD, hwndButtonWD;
  31. WORD wHotkeyA1, wHotkeyA2;
  32. UINT iSetResultA1, iSetResultA2;
  33. HMENU hMenubar, hMenu, hMenuB, hMenuC;
  34. INITCOMMONCONTROLSEX icex;
  35. NOTIFYICONDATA iconTray;
  36. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  37. LRESULT CALLBACK WndProcB(HWND, UINT, WPARAM, LPARAM);
  38. LRESULT CALLBACK WndProcC(HWND, UINT, WPARAM, LPARAM);
  39. LRESULT CALLBACK WndProcD(HWND, UINT, WPARAM, LPARAM);
  40. LRESULT CALLBACK WndProcE(HWND, UINT, WPARAM, LPARAM);
  41. PROCESS_INFORMATION CreateChildProcess(char szCmdline[], HANDLE hChildStdWr);
  42. std::string ReadFromPipe(PROCESS_INFORMATION piProcInfo, HANDLE hChildStdRd);
  43. void trayDrawIcon(HWND hwnd);
  44. void AddMenus(HWND);
  45. void resetwKillRing(HWND hwnd);
  46. void setConfiguration(HWND hwnd, HWND hotKeyHandle[]);
  47. void saveConfiguration(HWND hwnd);
  48. void toClipboard(const std::string &s);
  49. std::string getClipboardText();
  50. LPWSTR stringToLPWSTR(const std::string& instr);
  51. std::string lpwstrToString(LPWSTR input);
  52. std::string doubleBSlash(std::string path);
  53. std::string silentCmdResult(char *command);
  54. std::string execPath();
  55. std::string getEditText(HWND hwndEditW);
  56. bool fileExists(const char *fileName);
  57. bool isDir(std::string path);
  58. void displayExcludeList(HWND hwndEdit, std::string passedString, std::string passedPath);
  59. void registerWordHotKey(HWND hHotKey, int ID);
  60. int gCmdShow;
  61.  
  62. int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR lpCmdLine, int nCmdShow)
  63. {
  64.     gCmdShow = nCmdShow;
  65.     MSG  msg;    
  66.     WNDCLASSW wc = {0};
  67.     wc.lpszClassName = L"wKillRing";
  68.     wc.hInstance     = hInstance;
  69.     wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
  70.     wc.lpfnWndProc   = WndProc;
  71.     wc.hCursor       = LoadCursor(0, IDC_ARROW);
  72.     wc.hIcon         = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON));
  73.     RegisterClassW(&wc);
  74.     hWindowa = CreateWindowW(wc.lpszClassName, L"wKillRing", WS_OVERLAPPEDWINDOW, 200, 200, 372, 244, 0, 0, hInstance, 0);//WS_MINIMIZEBOX //WS_OVERLAPPEDWINDOW | WS_VISIBLE
  75.    
  76.     WNDCLASSW wcB = {0};
  77.     wcB.lpszClassName = L"Edit_paste-A";
  78.     wcB.hInstance     = hInstance;
  79.     wcB.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
  80.     wcB.lpfnWndProc   = WndProcB;
  81.     wcB.hCursor       = LoadCursor(0, IDC_ARROW);
  82.     wcB.hIcon         = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON));
  83.     RegisterClassW(&wcB);
  84.     hWindowb = CreateWindowW(wcB.lpszClassName, L"Edit paste-A", WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX, 360, 234, 500, 212, 0, 0, hInstance, 0);
  85.     ShowWindow(hWindowb, SW_HIDE);
  86.  
  87.     WNDCLASSW wcC = {0};
  88.     wcC.lpszClassName = L"Edit_paste-B";
  89.     wcC.hInstance     = hInstance;
  90.     wcC.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
  91.     wcC.lpfnWndProc   = WndProcC;
  92.     wcC.hCursor       = LoadCursor(0, IDC_ARROW);
  93.     wcC.hIcon         = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON));
  94.     RegisterClassW(&wcC);
  95.     hWindowc = CreateWindowW(wcC.lpszClassName, L"Edit paste-B", WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX, 360, 234, 500, 212, 0, 0, hInstance, 0);
  96.     ShowWindow(hWindowc, SW_HIDE);
  97.  
  98.     WNDCLASSW wcD = {0};
  99.     wcD.lpszClassName = L"Edit_paste-C";
  100.     wcD.hInstance     = hInstance;
  101.     wcD.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
  102.     wcD.lpfnWndProc   = WndProcD;
  103.     wcD.hCursor       = LoadCursor(0, IDC_ARROW);
  104.     wcD.hIcon         = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON));
  105.     RegisterClassW(&wcD);
  106.     hWindowd = CreateWindowW(wcD.lpszClassName, L"Edit paste-C", WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX, 360, 234, 500, 212, 0, 0, hInstance, 0);
  107.     ShowWindow(hWindowd, SW_HIDE);
  108.  
  109.     WNDCLASSW wcE = {0};
  110.     wcE.lpszClassName = L"Edit_paste-D";
  111.     wcE.hInstance     = hInstance;
  112.     wcE.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
  113.     wcE.lpfnWndProc   = WndProcE;
  114.     wcE.hCursor       = LoadCursor(0, IDC_ARROW);
  115.     wcE.hIcon         = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON));
  116.     RegisterClassW(&wcE);
  117.     hWindowe = CreateWindowW(wcE.lpszClassName, L"Edit paste-D", WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX, 360, 234, 500, 212, 0, 0, hInstance, 0);
  118.     ShowWindow(hWindowe, SW_HIDE);
  119.  
  120.     icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
  121.     icex.dwICC = ICC_HOTKEY_CLASS;
  122.     InitCommonControlsEx(&icex);
  123.     RegisterHotKey(NULL, 1, MOD_CONTROL | MOD_SHIFT | MOD_NOREPEAT, 0x55);
  124.     RegisterHotKey(NULL, 2, MOD_CONTROL | MOD_SHIFT | MOD_NOREPEAT, 0x49);
  125.     RegisterHotKey(NULL, 3, MOD_CONTROL | MOD_SHIFT | MOD_NOREPEAT, 0x4F);
  126.     RegisterHotKey(NULL, 4, MOD_CONTROL | MOD_SHIFT | MOD_NOREPEAT, 0x50);
  127.     toClipboard("");
  128.  
  129.     while(GetMessage(&msg, NULL, 0, 0))
  130.     {
  131.         TranslateMessage(&msg);
  132.         DispatchMessage(&msg);
  133.  
  134.         if(showWindowB)
  135.         {
  136.             ShowWindow(hWindowb, nCmdShow);
  137.         }
  138.         else if(!showWindowB)
  139.         {
  140.             ShowWindow(hWindowb, SW_HIDE);
  141.         }
  142.         if(showWindowC)
  143.         {
  144.             ShowWindow(hWindowc, nCmdShow);
  145.         }
  146.         else if(!showWindowC)
  147.         {
  148.             ShowWindow(hWindowc, SW_HIDE);
  149.         }
  150.         if(showWindowD)
  151.         {
  152.             ShowWindow(hWindowd, nCmdShow);
  153.         }
  154.         else if(!showWindowD)
  155.         {
  156.             ShowWindow(hWindowd, SW_HIDE);
  157.         }
  158.         if(showWindowE)
  159.         {
  160.             ShowWindow(hWindowe, nCmdShow);
  161.         }
  162.         else if(!showWindowE)
  163.         {
  164.             ShowWindow(hWindowe, SW_HIDE);
  165.         }
  166.         if(msg.message == WM_HOTKEY)
  167.         {
  168.             OutputDebugStringW(L"WM_HOTKEY received\n");
  169.             switch(msg.wParam)
  170.             {
  171.                 case HOTKEYPASTEA:
  172.                     toClipboard(getEditText(hwndEditWA));
  173.                     break;
  174.                 case HOTKEYPASTEB:
  175.                     toClipboard(getEditText(hwndEditWB));
  176.                     break;
  177.                 case HOTKEYPASTEC:
  178.                     toClipboard(getEditText(hwndEditWC));
  179.                     break;
  180.                 case HOTKEYPASTED:
  181.                     toClipboard(getEditText(hwndEditWD));
  182.                     break;
  183.                 case HOTKEYRINGLEFT:
  184.                     if(killRing.empty())
  185.                     {
  186.                         MessageBox(hWindowa, "Fill the clipboard first", "wKillRing", MB_ICONWARNING | MB_OK);
  187.                     }
  188.                     else
  189.                     {
  190.                         killRingPos--;
  191.                         if(killRingPos<0)
  192.                         {
  193.                             killRingPos = killRing.size() - 1;
  194.                         }
  195.                         toClipboard(killRing.at(killRingPos));
  196.                     }
  197.                     break;
  198.                 case HOTKEYRINGRIGHT:
  199.                     if(killRing.empty())
  200.                     {
  201.                         MessageBox(hWindowa, "Fill the clipboard first", "wKillRing", MB_ICONWARNING | MB_OK);
  202.                     }
  203.                     else
  204.                     {
  205.                         killRingPos++;
  206.                         if(killRingPos>killRing.size() - 1)
  207.                         {
  208.                             killRingPos = 0;
  209.                         }
  210.                         toClipboard(killRing.at(killRingPos));
  211.                     }
  212.                     break;
  213.                 default:
  214.                     break;
  215.             }
  216.         }
  217.     }
  218.     return (int) msg.wParam;
  219. }
  220.  
  221. LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  222. {
  223.     trayDrawIcon(hWindowa);
  224.     GetModuleFileName(NULL, wKillRingPath, MAX_PATH);
  225.     exeFullPath = doubleBSlash(wKillRingPath);
  226.     exePath = execPath();
  227.     confPath = getenv("appdata");
  228.     confPath += "\\wKillRing";
  229.     if(isDir(confPath) != true)
  230.     {
  231.         command = "C:\\windows\\system32\\cmd.exe /c mkdir \"";
  232.         command.append(confPath);
  233.         command.append("\"");
  234.         strcpy(ccommand, command.c_str());
  235.         silentCmdResult(ccommand);
  236.     }
  237.     SetTimer(hwnd, ID_TIMERA, 1000, (TIMERPROC) NULL);
  238.     switch(msg)
  239.     {
  240.     case WM_CREATE:
  241.     {
  242.         AddMenus(hwnd);
  243.  
  244.         hTextA1 = CreateWindowEx(0, WC_STATIC, ("Iterate to the left of the ring :"), WS_VISIBLE | WS_CHILD | WS_GROUP | SS_LEFT, 18, 17, 225, 19, hwnd, (HMENU)ID_TEXTA1, GetModuleHandle(NULL), 0);
  245.         hHotKeyA1 = CreateWindowEx(0, HOTKEY_CLASS, (""), WS_VISIBLE | WS_CHILD | WS_TABSTOP, 226, 15, 112, 23, hwnd, (HMENU)ID_HOTKEYA1, GetModuleHandle(NULL), 0);
  246.         hTextA3 = CreateWindowEx(0, WC_STATIC, ("Iterate to the right of the ring :"), WS_VISIBLE | WS_CHILD | WS_GROUP | SS_LEFT, 18, 45, 225, 19, hwnd, (HMENU)ID_TEXTA3, GetModuleHandle(NULL), 0);
  247.         hHotKeyA2 = CreateWindowEx(0, HOTKEY_CLASS, (""), WS_VISIBLE | WS_CHILD | WS_TABSTOP, 226, 44, 112, 23, hwnd, (HMENU)ID_HOTKEYA1, GetModuleHandle(NULL), 0);
  248.         hButtonA1 = CreateWindowEx(0, WC_BUTTON, ("Save changes"), WS_VISIBLE | WS_CHILD | WS_TABSTOP, 133, 75, 102, 23, hwnd, (HMENU)ID_BUTTONA1, GetModuleHandle(NULL), 0);
  249.  
  250.         hButtonPasteA = CreateWindowEx(0, WC_BUTTON, ("Edit paste-A"), WS_VISIBLE | WS_CHILD | WS_TABSTOP, 48, 112, 126, 23, hwnd, (HMENU)ID_BUTTONPASTEA, GetModuleHandle(NULL), 0);
  251.         hButtonPasteB = CreateWindowEx(0, WC_BUTTON, ("Edit paste-B"), WS_VISIBLE | WS_CHILD | WS_TABSTOP, 180, 112, 126, 23, hwnd, (HMENU)ID_BUTTONPASTEB, GetModuleHandle(NULL), 0);
  252.         hButtonPasteC = CreateWindowEx(0, WC_BUTTON, ("Edit paste-C"), WS_VISIBLE | WS_CHILD | WS_TABSTOP, 48, 145, 126, 23, hwnd, (HMENU)ID_BUTTONPASTEC, GetModuleHandle(NULL), 0);
  253.         hButtonPasteD = CreateWindowEx(0, WC_BUTTON, ("Edit paste-D"), WS_VISIBLE | WS_CHILD | WS_TABSTOP, 180, 145, 126, 23, hwnd, (HMENU)ID_BUTTONPASTED, GetModuleHandle(NULL), 0);
  254.  
  255.         HWND hotKeyHandle[] = {hHotKeyA1, hHotKeyA2};
  256.         setConfiguration(hwnd, hotKeyHandle);
  257.         break;
  258.     }
  259.     case WM_COMMAND:
  260.             if(LOWORD(wParam)==ID_BUTTONPASTEA)
  261.             {
  262.                 showWindowB = true;
  263.                 SetActiveWindow(hWindowb);
  264.                 break;
  265.             }
  266.             else if(LOWORD(wParam)==ID_BUTTONPASTEB)
  267.             {
  268.                 showWindowC = true;
  269.                 SetActiveWindow(hWindowc);
  270.                 break;
  271.             }
  272.             else if(LOWORD(wParam)==ID_BUTTONPASTEC)
  273.             {
  274.                 showWindowD = true;
  275.                 SetActiveWindow(hWindowd);
  276.                 break;
  277.             }
  278.             else if(LOWORD(wParam)==ID_BUTTONPASTED)
  279.             {
  280.                 showWindowE = true;
  281.                 SetActiveWindow(hWindowe);
  282.                 break;
  283.             }
  284.             else if(LOWORD(wParam)==ID_MENUB)
  285.             {
  286.                 Shell_NotifyIcon(NIM_DELETE, &iconTray);
  287.                 DestroyWindow(hwnd);
  288.                 PostQuitMessage(0);
  289.                 break;
  290.             }
  291.             else if(LOWORD(wParam)==IDM_START_WITH_WINDOWS)
  292.             {
  293.                 if(!startWithWindows)
  294.                 {
  295.                     command = "schtasks /Create /SC ONLOGON /TN \"Start-wKillRing\" /RL HIGHEST /F /TR \"'";
  296.                     command.append(exeFullPath);
  297.                     command.append("'\"");
  298.                     strcpy(ccommand, command.c_str());
  299.                     commandResult = silentCmdResult(ccommand);
  300.                     if(commandResult.find("SUC") != std::string::npos || commandResult.find("ussie") != std::string::npos)
  301.                     {
  302.                         MessageBoxA(NULL, "Startup task successfully created", "Start with Windows", MB_ICONINFORMATION | MB_OK);
  303.                     }
  304.                     else if(commandResult.find("SUC") == std::string::npos || commandResult.find("ussie") != std::string::npos)
  305.                     {
  306.                         MessageBoxA(NULL, "Could not create startup task\nPlease execute wKillRing as Administrator", "Start with Windows", MB_ICONWARNING | MB_OK);
  307.                     }
  308.                     ModifyMenuA(hMenu, IDM_START_WITH_WINDOWS, MF_BYCOMMAND | MF_CHECKED, IDM_START_WITH_WINDOWS, "Start with Windows");
  309.                     startWithWindows = true;
  310.                 }
  311.                 else
  312.                 {
  313.                     command = "schtasks /Delete /TN \"Start-wKillRing\" /F";
  314.                     strcpy(ccommand, command.c_str());
  315.                     commandResult = silentCmdResult(ccommand);
  316.                     if(commandResult.find("SUC") != std::string::npos || commandResult.find("ussie") != std::string::npos)
  317.                     {
  318.                         MessageBoxA(NULL, "Startup task successfully deleted", "Start with Windows", MB_ICONINFORMATION | MB_OK);
  319.                     }
  320.                     ModifyMenuA(hMenu, IDM_START_WITH_WINDOWS, MF_BYCOMMAND | MF_UNCHECKED, IDM_START_WITH_WINDOWS, "Start with Windows");
  321.                     startWithWindows = false;
  322.                 }
  323.                 break;
  324.             }
  325.             else if(LOWORD(wParam)==IDM_RESET)
  326.             {
  327.                 resetwKillRing(hwnd);
  328.                 break;
  329.             }
  330.             else if(LOWORD(wParam)==IDM_ABOUT)
  331.             {
  332.                 MessageBox(hwnd, "wKillRing is a tool that offers a killRing\n"
  333.                                  "for copy and paste clipboard in Windows.\n"
  334.                                  "\n"
  335.                                  "You can change the binding to your\n"
  336.                                  "liking to iterate through the ring,\n"
  337.                                  "press CTRL + V to paste the selection.\n"
  338.                                  "\n"
  339.                                  "There is also 4 ready to paste text fields\n"
  340.                                  "that you can push to the clipboard\n"
  341.                                  "using CTRL + SHIFT + U, I , O or P,\n"
  342.                                  "press CTRL + V to paste the selection.\n"
  343.                                  "\n"
  344.                                  "On 01/26/19  wKillRing uses a Ms-PL.\n"
  345.                                  "Please contact me at maxime.p.jolly@gmail.com\n"
  346.                                  "if you have any questions or suggestions.\n",
  347.                                  "Informations", MB_ICONQUESTION);
  348.                 break;
  349.             }
  350.             else if(LOWORD(wParam)==ID_BUTTONA1)
  351.             {
  352.                 saveConfiguration(hwnd);
  353.             }
  354.             break;
  355.         case WM_HOTKEY:
  356.             showWindowB = false;
  357.             break;
  358.         case WM_KEYDOWN:
  359.             if (wParam == VK_ESCAPE)
  360.             {
  361.                 if(MessageBox(NULL, "Are you sure you want to quit?", "wKillRing",  MB_YESNOCANCEL) == IDYES)
  362.                 {
  363.                     SendMessage(hwnd, WM_CLOSE, 0, 0);
  364.                 }          
  365.             }
  366.             break;
  367.         case WM_TIMER:
  368.             switch (wParam)
  369.             {
  370.                 case ID_TIMERA:
  371.                 {
  372.                     std::string checkClipboard = getClipboardText();
  373.                     if(copyStarted && !checkClipboard.empty())
  374.                     {
  375.                         auto it = std::find(killRing.begin(), killRing.end(), checkClipboard);
  376.                         if(it == killRing.end())
  377.                         {
  378.                             killRing.push_back(getClipboardText());
  379.                             killRingPos++;
  380.                         }
  381.                     }
  382.                     else if(!copyStarted && !checkClipboard.empty())
  383.                     {
  384.                         killRing.push_back(checkClipboard);
  385.                         killRingPos++;
  386.                         copyStarted = true;
  387.                     }
  388.                     break;
  389.                 }
  390.                 default:
  391.                     break;
  392.             }
  393.             break;
  394.         case WM_SYSCOMMAND:
  395.             if((wParam & 0xFFF0) == SC_MINIMIZE)
  396.             {
  397.                 //trayDrawIcon(hWindowa);
  398.                 //SetWindowLong(hWindowa, GWL_STYLE, GetWindowLong(hWindowa, GWL_STYLE) & ~WS_MINIMIZEBOX);
  399.                 SetWindowLong(hWindowa, GWL_EXSTYLE, GetWindowLong(hWindowa, GWL_EXSTYLE) & ~WS_VISIBLE);
  400.                 //SetWindowLong(hWindowa, GWL_EXSTYLE, WS_EX_NOACTIVATE);
  401.                 UpdateWindow(hWindowa);
  402.                 trayDrawIcon(hWindowa);
  403.                 ShowWindow(hWindowa, SW_HIDE);             
  404.             }
  405.             break;
  406.         case WM_TRAY:
  407.             switch (lParam)
  408.             {
  409.                 //add function for reducing windows = hide hWindowa
  410.                 case WM_LBUTTONUP:
  411.                     SetWindowLong(hWindowa, GWL_EXSTYLE, WS_EX_TOOLWINDOW);//WS_EX_NOACTIVATE
  412.                     SetWindowLong(hWindowa, GWL_STYLE, GetWindowLong(hWindowa, GWL_STYLE) & ~WS_MAXIMIZEBOX);
  413.                     ShowWindow(hWindowa, SW_SHOW);
  414.                     break;
  415.                 case WM_RBUTTONUP:
  416.                     hMenuC = CreatePopupMenu();
  417.                     AppendMenu(hMenuC, MF_STRING, ID_MENUB, "Stop wKillRing");
  418.                     SetMenuDefaultItem(hMenuC, 0, TRUE);
  419.                     SetForegroundWindow(hWindowa);
  420.                     POINT pt;
  421.                     GetCursorPos(&pt);
  422.                     TrackPopupMenu(hMenuC, TPM_RIGHTALIGN|TPM_BOTTOMALIGN|TPM_RIGHTBUTTON, pt.x, pt.y, 0, hWindowa, NULL);
  423.                     DestroyMenu(hMenuC);
  424.                     hMenu = NULL;
  425.                     PostMessage(hWindowa, WM_NULL, 0, 0);
  426.                     break;
  427.             }
  428.             break;
  429.         case WM_CLOSE:
  430.             //trayDrawIcon(hWindowa);
  431.             ShowWindow(hWindowa, SW_HIDE);
  432.             return 1;
  433.             break;
  434.         case WM_DESTROY:
  435.             //PostQuitMessage(0);
  436.             break;
  437.         default:
  438.             break;
  439.     }
  440.     return DefWindowProcW(hwnd, msg, wParam, lParam);
  441. }
  442.  
  443. LRESULT CALLBACK WndProcB(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  444. {
  445.     std::string filePath = confPath;
  446.     filePath.append("\\pasteA.txt");
  447.     std::ifstream fileD(filePath);
  448.     if(!fileD.good())
  449.     {
  450.         std::ofstream fileF(filePath, std::ios::out | std::ios::trunc);
  451.         fileF<<"Le magasin est ouvert de 13h a 17h"<<std::endl;
  452.         fileF<<"sauf le mercredi, sur rdv";
  453.         fileF.close();
  454.     }
  455.     std::string excCont;
  456.     switch(msg)
  457.     {
  458.         case WM_KEYDOWN:
  459.             if (wParam == VK_ESCAPE)
  460.             {
  461.                 SendMessage(hwnd, WM_CLOSE, 0, 0);
  462.             }    
  463.             break;
  464.         case WM_CREATE:
  465.             hwndEditWA = CreateWindowW(L"Edit", NULL, ES_MULTILINE | ES_WANTRETURN | WS_HSCROLL | WS_VSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_CLIPSIBLINGS, 11, 10, 472, 145, hwnd, (HMENU)ID_EDITWA, GetModuleHandle(NULL), NULL); //ES_AUTOVSCROLL //ES_WANTRETURN
  466.             hwndButtonWA = CreateWindowW(L"Button", L"Save", WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS, 195, 158, 95, 21, hwnd, (HMENU)ID_BUTTONWA, GetModuleHandle(NULL), NULL);
  467.             displayExcludeList(hwndEditWA, excCont, filePath);
  468.             break;
  469.         case WM_COMMAND:
  470.             if(LOWORD(wParam)==ID_BUTTONWA)
  471.             {
  472.                 std::ofstream fileB(filePath, std::ios::out | std::ios::trunc);
  473.                 fileB<<getEditText(hwndEditWA);
  474.                 fileB.close();
  475.                 SendMessage(hwnd, WM_CLOSE, 0, 0);
  476.             }
  477.             break;
  478.         case WM_CLOSE:
  479.             showWindowB = false;
  480.             SetActiveWindow(hWindowa);
  481.             return 0;
  482.             break;
  483.         default:
  484.             break;
  485.     }
  486.     return DefWindowProcW(hwnd, msg, wParam, lParam);
  487. }
  488.  
  489. LRESULT CALLBACK WndProcC(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  490. {
  491.     std::string filePath = confPath;
  492.     filePath.append("\\pasteB.txt");
  493.     std::ifstream fileD(filePath);
  494.     if(!fileD.good())
  495.     {
  496.         std::ofstream fileF(filePath, std::ios::out | std::ios::trunc);
  497.         fileF<<"Pour rediriger vos mails Zimbra rendez-vous dans"<<std::endl;
  498.         fileF<<"Préférences/ Mail/ Reception des mails/ Arrivé d'un mail : faire suivre une copie à :"<<std::endl;
  499.         fileF<<"et ajoutez l'adresse mail désirée";
  500.         fileF.close();
  501.     }
  502.     std::string excCont;
  503.     switch(msg)
  504.     {
  505.         case WM_KEYDOWN:
  506.             if (wParam == VK_ESCAPE)
  507.             {
  508.                 SendMessage(hwnd, WM_CLOSE, 0, 0);
  509.             }    
  510.             break;
  511.         case WM_CREATE:
  512.             hwndEditWB = CreateWindowW(L"Edit", NULL, ES_MULTILINE | ES_WANTRETURN | WS_HSCROLL | WS_VSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_CLIPSIBLINGS, 11, 10, 472, 145, hwnd, (HMENU)ID_EDITWB, GetModuleHandle(NULL), NULL); //ES_AUTOVSCROLL //ES_WANTRETURN
  513.             hwndButtonWB = CreateWindowW(L"Button", L"Save", WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS, 195, 158, 95, 21, hwnd, (HMENU)ID_BUTTONWB, GetModuleHandle(NULL), NULL);
  514.             displayExcludeList(hwndEditWB, excCont, filePath);
  515.             break;
  516.         case WM_COMMAND:
  517.             if(LOWORD(wParam)==ID_BUTTONWB)
  518.             {
  519.                 std::ofstream fileB(filePath, std::ios::out | std::ios::trunc);
  520.                 fileB<<getEditText(hwndEditWB);
  521.                 fileB.close();
  522.                 SendMessage(hwnd, WM_CLOSE, 0, 0);
  523.             }
  524.             break;
  525.         case WM_CLOSE:
  526.             showWindowC = false;
  527.             SetActiveWindow(hWindowa);
  528.             return 0;
  529.             break;
  530.         default:
  531.             break;
  532.     }
  533.     return DefWindowProcW(hwnd, msg, wParam, lParam);
  534. }
  535.  
  536. LRESULT CALLBACK WndProcD(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  537. {
  538.     std::string filePath = confPath;
  539.     filePath.append("\\pasteC.txt");
  540.     std::ifstream fileD(filePath);
  541.     if(!fileD.good())
  542.     {
  543.         std::ofstream fileF(filePath, std::ios::out | std::ios::trunc);
  544.         fileF<<"Maleureusement cet article n'est plus disponible en magasin."<<std::endl;
  545.         fileF<<"Une commande de réaprovisionement va bientôt être passée,"<<std::endl;
  546.         fileF<<"il faut alors compter un mois pour la récéption du matériel.";
  547.         fileF.close();
  548.     }
  549.     std::string excCont;
  550.     switch(msg)
  551.     {
  552.         case WM_KEYDOWN:
  553.             if (wParam == VK_ESCAPE)
  554.             {
  555.                 SendMessage(hwnd, WM_CLOSE, 0, 0);
  556.             }    
  557.             break;
  558.         case WM_CREATE:
  559.             hwndEditWC = CreateWindowW(L"Edit", NULL, ES_MULTILINE | ES_WANTRETURN | WS_HSCROLL | WS_VSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_CLIPSIBLINGS, 11, 10, 472, 145, hwnd, (HMENU)ID_EDITWC, GetModuleHandle(NULL), NULL); //ES_AUTOVSCROLL //ES_WANTRETURN
  560.             hwndButtonWC = CreateWindowW(L"Button", L"Save", WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS, 195, 158, 95, 21, hwnd, (HMENU)ID_BUTTONWC, GetModuleHandle(NULL), NULL);
  561.             displayExcludeList(hwndEditWC, excCont, filePath);
  562.             break;
  563.         case WM_COMMAND:
  564.             if(LOWORD(wParam)==ID_BUTTONWC)
  565.             {
  566.                 std::ofstream fileB(filePath, std::ios::out | std::ios::trunc);
  567.                 fileB<<getEditText(hwndEditWC);
  568.                 fileB.close();
  569.                 SendMessage(hwnd, WM_CLOSE, 0, 0);
  570.             }
  571.             break;
  572.         case WM_CLOSE:
  573.             showWindowD = false;
  574.             SetActiveWindow(hWindowa);
  575.             return 0;
  576.             break;
  577.         default:
  578.             break;
  579.     }
  580.     return DefWindowProcW(hwnd, msg, wParam, lParam);
  581. }
  582.  
  583. LRESULT CALLBACK WndProcE(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  584. {
  585.     std::string filePath = confPath;
  586.     filePath.append("\\pasteD.txt");
  587.     std::ifstream fileD(filePath);
  588.     if(!fileD.good())
  589.     {
  590.         std::ofstream fileF(filePath, std::ios::out | std::ios::trunc);
  591.         fileF<<"Have you tried turning it off & on again?";
  592.         fileF.close();
  593.     }
  594.     std::string excCont;
  595.     switch(msg)
  596.     {
  597.         case WM_KEYDOWN:
  598.             if (wParam == VK_ESCAPE)
  599.             {
  600.                 SendMessage(hwnd, WM_CLOSE, 0, 0);
  601.             }    
  602.             break;
  603.         case WM_CREATE:
  604.             hwndEditWD = CreateWindowW(L"Edit", NULL, ES_MULTILINE | ES_WANTRETURN | WS_HSCROLL | WS_VSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_CLIPSIBLINGS, 11, 10, 472, 145, hwnd, (HMENU)ID_EDITWD, GetModuleHandle(NULL), NULL); //ES_AUTOVSCROLL //ES_WANTRETURN
  605.             hwndButtonWD = CreateWindowW(L"Button", L"Save", WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS, 195, 158, 95, 21, hwnd, (HMENU)ID_BUTTONWD, GetModuleHandle(NULL), NULL);
  606.             displayExcludeList(hwndEditWD, excCont, filePath);
  607.             break;
  608.         case WM_COMMAND:
  609.             if(LOWORD(wParam)==ID_BUTTONWD)
  610.             {
  611.                 std::ofstream fileB(filePath, std::ios::out | std::ios::trunc);
  612.                 fileB<<getEditText(hwndEditWD);
  613.                 fileB.close();
  614.                 SendMessage(hwnd, WM_CLOSE, 0, 0);
  615.             }
  616.             break;
  617.         case WM_CLOSE:
  618.             showWindowE = false;
  619.             SetActiveWindow(hWindowa);
  620.             return 0;
  621.             break;
  622.         default:
  623.             break;
  624.     }
  625.     return DefWindowProcW(hwnd, msg, wParam, lParam);
  626. }
  627.  
  628. void AddMenus(HWND hwnd)
  629. {
  630.     hMenubar = CreateMenu();
  631.     hMenu = CreateMenu();
  632.     hMenuB = CreateMenu();
  633.     AppendMenuW(hMenu, MF_STRING, IDM_START_WITH_WINDOWS, L"&Start with Windows");
  634.     AppendMenuW(hMenu, MF_SEPARATOR, 0, NULL);
  635.     AppendMenuW(hMenu, MF_STRING, IDM_RESET, L"&Reset");
  636.     AppendMenuW(hMenubar, MF_POPUP, (UINT_PTR) hMenu, L"&More");
  637.     AppendMenuW(hMenuB, MF_STRING, IDM_ABOUT, L"About");
  638.     AppendMenuW(hMenubar, MF_POPUP, (UINT_PTR) hMenuB, L"&?");
  639.     SetMenu(hwnd, hMenubar);
  640. }
  641.  
  642. void toClipboard(const std::string &s)
  643. {
  644.     OpenClipboard(0);
  645.     EmptyClipboard();  
  646.     HGLOBAL hg=GlobalAlloc(GMEM_MOVEABLE,s.size()+1);
  647.     if (!hg)
  648.     {
  649.         CloseClipboard();
  650.         return;
  651.     }
  652.     memcpy(GlobalLock(hg),s.c_str(),s.size()+1);
  653.     GlobalUnlock(hg);
  654.     SetClipboardData(CF_TEXT,hg);
  655.     CloseClipboard();
  656.     GlobalFree(hg);
  657. }
  658.  
  659. std::string getClipboardText()
  660. {
  661.     std::string text = "";
  662.     OpenClipboard(0);
  663.     if(IsClipboardFormatAvailable(CF_TEXT))
  664.     {
  665.         HANDLE hData = GetClipboardData(CF_TEXT);
  666.         char * pszText = static_cast<char*>(GlobalLock(hData));
  667.         text = pszText;
  668.         GlobalUnlock(hData);
  669.     }
  670.     CloseClipboard();
  671.     return text;
  672. }
  673.  
  674. void resetwKillRing(HWND hwnd)
  675. {
  676.     std::string filePath = confPath;
  677.     filePath.append("\\wKillRing.cfg");
  678.     std::ofstream confFile(filePath, std::ios::out);
  679.     SendMessage(hHotKeyA1, HKM_SETHOTKEY, MAKEWORD(0x43, HOTKEYF_ALT), 0);
  680.     SendMessage(hHotKeyA2, HKM_SETHOTKEY, MAKEWORD(0x56, HOTKEYF_ALT), 0);
  681.     wHotkeyA1 = (WORD) SendMessage(hHotKeyA1, HKM_GETHOTKEY, 0, 0);
  682.     wHotkeyA2 = (WORD) SendMessage(hHotKeyA2, HKM_GETHOTKEY, 0, 0);
  683.     iSetResultA1 = SendMessage(hwnd, WM_SETHOTKEY, wHotkeyA1, 0);
  684.     iSetResultA2 = SendMessage(hwnd, WM_SETHOTKEY, wHotkeyA2, 0);
  685.     confFile<<"leftOfKillring="<<wHotkeyA1<<"\n";
  686.     confFile<<"rightOfKillring="<<wHotkeyA2<<"\n";
  687.     confFile<<"startWithWindows="<<"0"<<"\n";
  688.     confFile.close();
  689. }
  690.  
  691. void setConfiguration(HWND hwnd, HWND hotKeyHandle[])
  692. {
  693.     std::string filePath, item, hotKey;
  694.     unsigned first, last;
  695.     unsigned short dHotKey;
  696.     int counter = 0, idCounter = 5;
  697.     filePath = confPath;
  698.     filePath.append("\\wKillRing.cfg");
  699.     if(!fileExists(filePath.c_str()))
  700.     {
  701.         resetwKillRing(hwnd);
  702.     }
  703.     else
  704.     {
  705.         std::ifstream inFile(filePath);
  706.         while(std::getline(inFile, item, '\n'))
  707.         {
  708.             first = item.find("=");
  709.             last = item.find('\n');
  710.             hotKey = item.substr(first,last-first);
  711.             hotKey.erase(0, 1);
  712.             if(item.find("startWithWindows") == std::string::npos)
  713.             {
  714.                 dHotKey = (unsigned short) strtoul(hotKey.c_str(), NULL, 0);
  715.                 SendMessage(hotKeyHandle[counter], HKM_SETHOTKEY, (WORD)dHotKey, 0);
  716.                 SendMessage(hwnd, WM_SETHOTKEY, (WORD)dHotKey, 0);
  717.                 registerWordHotKey(hotKeyHandle[counter], idCounter);
  718.                 counter++;
  719.                 idCounter++;
  720.             }
  721.             else
  722.             {
  723.                 startWithWindows = atoi(hotKey.c_str());
  724.             }
  725.         }
  726.         inFile.close();
  727.     }
  728. }
  729.  
  730. void saveConfiguration(HWND hwnd)
  731. {
  732.     std::string filePath = confPath;
  733.     filePath.append("\\wKillRing.cfg");
  734.     std::ofstream confFile(filePath, std::ios::out);
  735.     UnregisterHotKey(NULL, 5);
  736.     UnregisterHotKey(NULL, 6);
  737.     wHotkeyA1 = (WORD) SendMessage(hHotKeyA1, HKM_GETHOTKEY, 0, 0);
  738.     wHotkeyA2 = (WORD) SendMessage(hHotKeyA2, HKM_GETHOTKEY, 0, 0);
  739.     iSetResultA1 = SendMessage(hwnd, WM_SETHOTKEY, wHotkeyA1, 0);
  740.     iSetResultA2 = SendMessage(hwnd, WM_SETHOTKEY, wHotkeyA2, 0);
  741.     registerWordHotKey(hHotKeyA1, 5);
  742.     registerWordHotKey(hHotKeyA2, 6);
  743.     confFile<<"copyFirstBuffer="<<wHotkeyA1<<"\n";
  744.     confFile<<"pasteFirstBuffer="<<wHotkeyA2<<"\n";
  745.     confFile<<"startWithWindows="<<startWithWindows<<"\n";
  746.     confFile.close();
  747. }
  748.  
  749. LPWSTR stringToLPWSTR(const std::string& instr)
  750. {
  751.     int bufferlen = ::MultiByteToWideChar(CP_ACP, 0, instr.c_str(), instr.size(), NULL, 0);
  752.     LPWSTR widestr = new WCHAR[bufferlen + 1];
  753.     ::MultiByteToWideChar(CP_ACP, 0, instr.c_str(), instr.size(), widestr, bufferlen);
  754.     widestr[bufferlen] = 0;
  755.     return widestr;
  756. }
  757.  
  758. std::string lpwstrToString(LPWSTR input)
  759. {
  760.     int cSize = WideCharToMultiByte (CP_ACP, 0, input, wcslen(input), NULL, 0, NULL, NULL);
  761.     std::string output(static_cast<size_t>(cSize), '\0');
  762.     WideCharToMultiByte (CP_ACP, 0, input, wcslen(input), reinterpret_cast<char*>(&output[0]), cSize, NULL, NULL);
  763.     return output;
  764. }
  765.  
  766. std::string doubleBSlash(std::string path)
  767. {
  768.     std::string reWrite;
  769.     int pLength = strlen(path.c_str());
  770.     for(int i=0; i<pLength; ++i)
  771.     {
  772.         if(path[i] == '\\')
  773.         {
  774.             reWrite.append("\\");
  775.         }
  776.         reWrite.push_back(path[i]);
  777.     }
  778.     return reWrite;
  779. }
  780.  
  781. PROCESS_INFORMATION CreateChildProcess(char szCmdline[], HANDLE hChildStdWr)
  782. {
  783.     PROCESS_INFORMATION piProcInfo;
  784.     STARTUPINFO siStartInfo;
  785.     bool bSuccess = FALSE;
  786.     ZeroMemory(&piProcInfo, sizeof(PROCESS_INFORMATION));
  787.     ZeroMemory(&siStartInfo, sizeof(STARTUPINFO));
  788.     siStartInfo.cb = sizeof(STARTUPINFO);
  789.     siStartInfo.hStdOutput = hChildStdWr;
  790.     siStartInfo.dwFlags |= STARTF_USESTDHANDLES;
  791.     bSuccess = CreateProcess(NULL, szCmdline, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &siStartInfo, &piProcInfo);
  792.     if(!bSuccess)
  793.     {
  794.         exit(1);
  795.     }
  796.     else
  797.     {
  798.         CloseHandle(hChildStdWr);
  799.     }
  800.     return piProcInfo;
  801. }
  802.  
  803. std::string ReadFromPipe(PROCESS_INFORMATION piProcInfo, HANDLE hChildStdRd)
  804. {
  805.     DWORD dwRead;
  806.     CHAR chBuf[BUFSIZE];
  807.     bool bSuccess = FALSE;
  808.     std::string out = "";
  809.     for(;;)
  810.     {
  811.         bSuccess=ReadFile(hChildStdRd, chBuf, BUFSIZE, &dwRead, NULL);
  812.         if(!bSuccess || dwRead == 0)
  813.         {
  814.             break;
  815.         }
  816.         std::string s(chBuf, dwRead);
  817.         out += s;
  818.     }
  819.     return out;
  820. }
  821.  
  822. std::string silentCmdResult(char *command)
  823. {
  824.     SECURITY_ATTRIBUTES sa;
  825.     sa.nLength = sizeof(SECURITY_ATTRIBUTES);
  826.     sa.bInheritHandle = TRUE;
  827.     sa.lpSecurityDescriptor = NULL;
  828.     std::string commandResult, check;
  829.     pipeHandles.resize(pipeHandles.size()+2);
  830.     procInf.resize(procInf.size()+1);
  831.     for(int i=0;i<2;i++)
  832.     {
  833.         pipeCounter++;
  834.     }
  835.     if(!CreatePipe(&pipeHandles.at(pipeCounter-1) , &pipeHandles.at(pipeCounter), &sa, 0))
  836.     {
  837.         exit(1);
  838.     }
  839.     if(!SetHandleInformation(pipeHandles.at(pipeCounter-1), HANDLE_FLAG_INHERIT, 0))
  840.     {
  841.         exit(1);
  842.     }
  843.     procInfCounter++;
  844.     procInf.at(procInfCounter) = CreateChildProcess(command, pipeHandles.at(pipeCounter));
  845.     commandResult = ReadFromPipe(procInf.at(procInfCounter), pipeHandles.at(pipeCounter-1));
  846.     CloseHandle(procInf.at(procInfCounter).hProcess);
  847.     CloseHandle(procInf.at(procInfCounter).hThread);
  848.     return commandResult;
  849. }
  850.  
  851. std::string execPath()
  852. {
  853.     char buffer[MAX_PATH];
  854.     GetModuleFileName(NULL, buffer, MAX_PATH);
  855.     std::string::size_type pos = std::string(buffer).find_last_of("\\/");
  856.     return std::string(buffer).substr(0, pos);
  857. }
  858.  
  859. bool fileExists(const char *fileName)
  860. {
  861.     std::ifstream infile(fileName);
  862.     return infile.good();
  863. }
  864.  
  865. bool isDir(std::string path)
  866. {
  867.     DWORD fileAt = GetFileAttributesA(path.c_str());
  868.     if(fileAt == INVALID_FILE_ATTRIBUTES)
  869.     {
  870.         return false;
  871.     }
  872.     else if(fileAt & FILE_ATTRIBUTE_DIRECTORY)
  873.     {
  874.         return true;
  875.     }
  876.     else
  877.     {
  878.         return false;
  879.     }
  880. }
  881.  
  882. void displayExcludeList(HWND hwndEdit, std::string passedString, std::string passedPath)
  883. {
  884.     std::ifstream inFileB(passedPath);
  885.     std::string reBuildString;
  886.     std::stringstream ssA, ssB;
  887.     ssA << passedString << std::endl;
  888.     while(getline(inFileB, passedString, '\n'))
  889.     {
  890.         OutputDebugString(ssA.str().c_str());
  891.         reBuildString = reBuildString + passedString + "\r\n";
  892.     }
  893.     ssB << reBuildString;
  894.     SetWindowText(hwndEdit, ssB.str().c_str());
  895.     inFileB.close();
  896. }
  897.  
  898. void registerWordHotKey(HWND hHotKey, int ID)
  899. {
  900.     BYTE loByte = 0, hiByte = 0;
  901.     WORD wHotkey = 0;
  902.     UINT fsMod = 0;
  903.     wHotkey = (WORD) SendMessage(hHotKey, HKM_GETHOTKEY, 0, 0);
  904.     loByte = LOBYTE(wHotkey);
  905.     hiByte = HIBYTE(wHotkey);
  906.     switch(hiByte)
  907.     {
  908.         case HOTKEYF_ALT :
  909.             fsMod = MOD_ALT;
  910.             break;
  911.         case HOTKEYF_CONTROL :
  912.             fsMod = MOD_CONTROL;
  913.             break;
  914.         case HOTKEYF_SHIFT :
  915.             fsMod = MOD_SHIFT;
  916.             break;
  917.         case HOTKEYF_CONTROL + HOTKEYF_SHIFT :
  918.             fsMod = MOD_CONTROL + MOD_SHIFT;
  919.             break;
  920.         case HOTKEYF_ALT + HOTKEYF_SHIFT :
  921.             fsMod = MOD_ALT + MOD_SHIFT;
  922.             break;
  923.         case HOTKEYF_ALT + HOTKEYF_CONTROL :
  924.             fsMod = MOD_ALT + MOD_CONTROL;
  925.             break;
  926.         default :
  927.             break;
  928.     }
  929.     if(!RegisterHotKey(NULL, ID, fsMod | MOD_NOREPEAT, loByte))
  930.     {
  931.         OutputDebugStringW(L"registerHotKey NOK");
  932.     }
  933.     else
  934.     {
  935.         OutputDebugStringW(L"registerHotKey OK");
  936.     }
  937. }
  938.  
  939. std::string getEditText(HWND hwndEditW)
  940. {
  941.     TCHAR buffy[1024];
  942.     GetWindowTextW(hwndEditW, (LPWSTR)buffy, 1024);
  943.     std::string paste = lpwstrToString((LPWSTR)buffy);
  944.     return paste;
  945. }
  946.  
  947. void trayDrawIcon(HWND hwnd)
  948. {
  949.     iconTray.cbSize = sizeof(NOTIFYICONDATA);
  950.     iconTray.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON));
  951.     iconTray.hWnd = hwnd;
  952.     strcpy(iconTray.szTip, "wKillRing");
  953.     iconTray.uCallbackMessage = WM_TRAY;
  954.     iconTray.uFlags = NIF_ICON|NIF_MESSAGE|NIF_TIP;
  955.     iconTray.uID = 666;
  956.     Shell_NotifyIcon(NIM_ADD, &iconTray);
  957.     HMENU g_menu = CreatePopupMenu();
  958.     AppendMenu(g_menu, MF_STRING, ID_MENUB, TEXT( "Exit" ));
  959. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement