Advertisement
mosaid

Untitled

Aug 13th, 2017
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 32.81 KB | None | 0 0
  1. //
  2. // MOSAID / 2015
  3. // c++ headers
  4. #include <iostream>
  5. #include <fstream>
  6. #include <string>
  7. #include <sstream>
  8. #include <vector>
  9. #include <stdio.h>
  10. #include <conio.h>
  11. #include <iomanip>
  12. #include <ctime>
  13. //winapi headers
  14. #include <windows.h>
  15. #include <tchar.h>
  16. #include <strsafe.h>
  17. #include <Shellapi.h>
  18. #include <Shlwapi.h>
  19. #include <shlobj.h>
  20. #include <commctrl.h>
  21. #include <Objbase.h>
  22. #include <TlHelp32.h>
  23.  
  24. #pragma comment(lib,"user32.lib")
  25. #pragma comment(lib,"Shell32.lib")
  26. #pragma comment(lib,"Gdi32.lib")
  27. #pragma comment(lib,"Advapi32.lib")
  28. #pragma comment(lib,"Comdlg32.lib")
  29. #pragma comment(lib,"Comctl32.lib")
  30. #pragma comment(lib,"Shlwapi.lib")
  31. #pragma comment(lib,"Ole32.lib")
  32.  
  33. #include "LimitSingleInstance.h"
  34. CLimitSingleInstance g_SingleInstanceObj(TEXT("Global\\{9DA0BEED-7248-450a-B27C-C0409BDC377D}"));
  35.  
  36. using namespace std;
  37.  
  38. struct Vv{
  39.        string name;
  40.        string index;
  41.        string path;
  42.        string command;
  43.        string password;
  44. };
  45.  
  46. vector<Vv> myVec;
  47. char buffer[7];
  48.  
  49. const HANDLE handle=GetStdHandle(STD_OUTPUT_HANDLE);
  50. const string findex[]={"10","12","13","14","15","16","17","18","19","21","23","24","25","26","27","28","29","30","31","32"};
  51. const string aindex[]={"00","11","22","33","44","55","66","77","88","99","01","02","03","04","05","06","07","08","09"};
  52.  
  53. INPUT_RECORD irInBuf[128];
  54. MOUSE_EVENT_RECORD ir;
  55. DWORD cNumRead;
  56. string str;
  57.  
  58. bool password();
  59. void gotoxy(int x, int y);
  60. void InitiateConsole(int x, int y, bool bb);
  61. bool WINAPI SetConsoleIcon();
  62. void color(DWORD);
  63. void parse(string& arg);
  64. void cls();
  65. void design();
  66. void choices();
  67. void initIniFile();
  68. void ReadIniFile();
  69. void DisplayError(LPCSTR lpszFunction);
  70. void handleInputEvents();
  71.  
  72. int main()
  73. {
  74.     if (g_SingleInstanceObj.IsAnotherInstanceRunning())
  75.     {
  76.    
  77.       return 0;
  78.     }    
  79.     SetWindowPos(GetConsoleWindow(),HWND_TOP,400,180,0,0,SWP_NOSIZE);  
  80.     InitiateConsole(60,30,true);   
  81.     SetConsoleIcon();
  82.     EXECUTION_STATE PrevES = SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_CONTINUOUS );
  83.     DWORD oldConsoleMod,ConsoleMod;
  84.     HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
  85.     GetConsoleMode(hStdin, &oldConsoleMod);
  86.     ConsoleMod = ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT;
  87.     SetConsoleMode(hStdin, ConsoleMod);
  88.     cls();
  89.     design();
  90.     initIniFile();
  91.     ReadIniFile();
  92.     choices();
  93.     while(true)
  94.     {    
  95.       gotoxy(44,2);
  96.       cout<<"     ";
  97.       gotoxy(44,2);
  98.       handleInputEvents();    
  99.     }
  100.     SetThreadExecutionState(PrevES);
  101.     SetConsoleMode(hStdin, oldConsoleMod);
  102.     return 0;
  103. }
  104. void translateMouseDBClick(int x, int y)
  105. {
  106.   string str("mm");
  107.   if( x>=30 && y>=10 && y<29) str =aindex[y-10];
  108.   if( x<30 && y>=4 && y<24)   str =findex[y-4];
  109.   if( x<10 && y==26)  str ="xx";
  110.   if( x>11 && x<30 && y==26)  str ="ss";
  111.   if( x<=9 && y==28)  str ="pp";
  112.   if( x>=10 && x<18 && y==28)  str ="rr";
  113.   if( x>=18 && x<30 && y==28)  str ="aa";
  114.   parse(str);
  115. }
  116. void handleInputEvents()
  117. {
  118.   char c;
  119.   HANDLE hStdin= GetStdHandle(STD_INPUT_HANDLE);
  120.   if (! ReadConsoleInput(hStdin,irInBuf,128,&cNumRead) )
  121.   DisplayError("ReadConsoleInput");
  122.   for (int i = 0; i < cNumRead; i++)
  123.     {
  124.         if(irInBuf[i].EventType == MOUSE_EVENT )
  125.         {
  126.           ir = irInBuf[i].Event.MouseEvent;
  127.           if(ir.dwEventFlags == DOUBLE_CLICK )
  128.           {
  129.             translateMouseDBClick(ir.dwMousePosition.X,ir.dwMousePosition.Y);
  130.           }
  131.         }
  132.         if(irInBuf[i].EventType == KEY_EVENT )
  133.         {      
  134.            if(irInBuf[i].Event.KeyEvent.bKeyDown)
  135.            {
  136.              c = irInBuf[i].Event.KeyEvent.uChar.AsciiChar;
  137.              str = c;
  138.              putchar(c);
  139.              c =getch();
  140.              str+=c;
  141.              putchar(c);
  142.              parse(str);
  143.              gotoxy(46,4);
  144.              cout<<"              ";
  145.              gotoxy(38,5);
  146.              cout<<"                 ";
  147.            }
  148.            if (! ReadConsoleInput(hStdin,irInBuf,128,&cNumRead) )
  149.              DisplayError("ReadConsoleInput");     
  150.         }
  151.     }
  152. }
  153. void choices()
  154. {
  155.       color(12);
  156.       gotoxy(2,26);
  157.       cout<<"xx: exit   ss: settings";
  158.       gotoxy(2,28);
  159.       cout<<"pp: pass rr: run aa: about";
  160.       color(11);
  161.       gotoxy(2,1);
  162.       cout<<"Folders :";
  163.       gotoxy(32,8);
  164.       cout<<"Apps :";
  165.       color(244);  
  166.       for(int i=0;i<20;i++)
  167.       {
  168.         gotoxy(1,4+i);
  169.         cout<<findex[i]<<":";
  170.         for(int k=0;k<myVec.size();k++)
  171.          {
  172.            if(myVec[k].index.compare(findex[i])==0)
  173.            {
  174.              gotoxy(5,4+i);
  175.              cout<<myVec[k].name;
  176.            }
  177.          }
  178.       }
  179.       color(10);
  180.       for(int i=0;i<19;i++)
  181.       {
  182.        gotoxy(32,10+i);
  183.        cout<<aindex[i]<<":";
  184.        for(int k=0;k<myVec.size();k++)
  185.          {
  186.            if(myVec[k].index.compare(aindex[i])==0)
  187.            {
  188.              gotoxy(36,10+i);
  189.              cout<<myVec[k].name;
  190.            }
  191.          }
  192.       }
  193. }
  194. void design()
  195. {  
  196.    color(240);
  197.    int k=0;
  198.    gotoxy(0,3);
  199.    for(int i=1;i<=638;i++){  
  200.    cout<<" ";
  201.    if(i%29==0){k++;gotoxy(0,3+k);}
  202.    }
  203.    color(11);
  204.    gotoxy(30,9);
  205.    cout<<"\xDA";
  206.    for(int i=0;i<=15;i++)cout<<"\xC4";
  207.    for(int i=0;i<=18;i++){
  208.    gotoxy(30,10+i);
  209.    cout<<"\xB3";
  210.    }
  211.    gotoxy(35,7);
  212.    color(14);
  213.    for(int i=0;i<25;i++)cout<<(char)223;
  214.    gotoxy(35,1);
  215.    for(int i=0;i<12;i++)cout<<(char)223;
  216.    for(int i=0;i<=5;i++)
  217.    {
  218.     gotoxy(35,6-i);
  219.     cout<<(char)219;
  220.    }
  221.    color(0);
  222.    color(11);
  223.    gotoxy(37,2);
  224.    cout<<"choice:";
  225.    gotoxy(37,4);
  226.    cout<<"password:";
  227.    
  228.    color(14);
  229.    char mosaid[]="MOSAID";
  230.    for(int i=0;i<6;i++)
  231.    {
  232.      gotoxy(32,1+i);
  233.      cout<<char(186)<<mosaid[i]<<char(186);//182
  234.    }
  235.    gotoxy(32,7);
  236.    cout<<char(223)<<char(223)<<char(223);
  237. }
  238.  
  239. void gotoxy(int x, int y)
  240. {
  241.   COORD coord = {x,y};
  242.   SetConsoleCursorPosition(handle,coord);
  243. }
  244.  
  245. void InitiateConsole(int x, int y, bool bb)
  246. {
  247.  if(bb) InitiateConsole(x-10,y-10,false);
  248.  COORD coord ={x,y};
  249.  SMALL_RECT rect = {0,0,x-1,y-1};
  250.  SetConsoleScreenBufferSize(handle,coord);
  251.  SetConsoleWindowInfo(handle,true,&rect);
  252.  SetConsoleTitle("Execute 1.0.15");
  253.  HWND hwnd  = GetConsoleWindow();
  254.  LONG style = GetWindowLong(hwnd , GWL_STYLE);
  255.  style = style & ~(WS_THICKFRAME);
  256.  style = style & ~(WS_MAXIMIZEBOX);
  257.  style = style & ~(WS_SYSMENU);
  258.  SetWindowLong(hwnd, GWL_STYLE, style);
  259.  HMENU hmenu = GetSystemMenu(hwnd, FALSE);
  260.  DeleteMenu(hmenu, SC_CLOSE, MF_BYCOMMAND);
  261. }
  262.  
  263. bool WINAPI SetConsoleIcon()
  264. {
  265.    HMODULE hMainMod = GetModuleHandle(0);
  266.    HICON hIcon =(HICON)LoadImage(hMainMod,"execute-1.0.15.ico",IMAGE_ICON,
  267.                                  0,0,LR_LOADFROMFILE|LR_DEFAULTSIZE);
  268.    typedef bool (WINAPI *PSetConsoleIcon)(HICON);
  269.    static PSetConsoleIcon pSetConsoleIcon = NULL;
  270.    if(pSetConsoleIcon == NULL)
  271.    pSetConsoleIcon = (PSetConsoleIcon)GetProcAddress(GetModuleHandle(_T("kernel32")), "SetConsoleIcon");
  272.    if(pSetConsoleIcon == NULL)
  273.    return false;
  274.    return pSetConsoleIcon(hIcon);
  275. }
  276. void ReadIniFile()
  277. {
  278.   ifstream ifs;
  279.   string line;
  280.   Vv tVv;
  281.   int i=0;
  282.   ifs.open("TrSettings.ini",ios::in);
  283.   if(!ifs.is_open())
  284.   {
  285.     DisplayError("ReadIniFile");
  286.     return;
  287.   }
  288.   while ( getline (ifs,line) )
  289.     {
  290.       if(line[0]=='[' && line[line.size()-1]==']')
  291.       {    
  292.         tVv.name.assign(line.begin()+1,line.end()-1);
  293.         i++;
  294.       }
  295.       if(line.compare(0,6,"index=")==0)
  296.       {
  297.         tVv.index.assign(line.begin()+6,line.end());
  298.         i++;
  299.       }
  300.       if(line.compare(0,5,"path=")==0)
  301.       {
  302.         tVv.path.assign(line.begin()+5,line.end());
  303.         i++;
  304.       }
  305.       if(line.compare(0,8,"command=")==0)
  306.       {
  307.         tVv.command.assign(line.begin()+8,line.end());
  308.         i++;
  309.       }
  310.       if(line.compare(0,9,"password=")==0)
  311.       {
  312.         tVv.password.assign(line.begin()+9,line.end());
  313.         i++;
  314.       }
  315.       if(i==5)
  316.       {
  317.         myVec.push_back(tVv);
  318.         i=0;
  319.       }
  320.     }
  321.   ifs.close();
  322.   SetFileAttributes("TrSettings.ini",FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM );
  323. }
  324. bool NotEmptyFile(LPCSTR filename)
  325. {
  326.     LARGE_INTEGER Size;
  327.     HANDLE Hfile;
  328.     bool result=false;
  329.     Hfile =  CreateFile(filename,GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);
  330.     if(Hfile!=INVALID_HANDLE_VALUE)
  331.     {
  332.        GetFileSizeEx(Hfile,&Size);
  333.        if(Size.LowPart)result=true;    
  334.     }
  335.     CloseHandle(Hfile);
  336.     return result; 
  337. }
  338. void initIniFile()
  339. {
  340.     if(NotEmptyFile("TrSettings.ini"))return;
  341.     HANDLE hFile;
  342.     DWORD dwWritten=0;
  343.     ostringstream ofs;
  344.     char data[MAX_PATH];
  345.     bool result=false;
  346.    
  347.     GetWindowsDirectory(data,MAX_PATH);
  348.     ofs<<"[command Prompt (cmd)]"<<endl;
  349.     ofs<<"index=00"<<endl;
  350.     ofs<<"path=cmd.exe"<<endl;
  351.     ofs<<"command=/s /k pushd "<<data[0]<<":\\"<<endl;
  352.     ofs<<"password=0"<<endl<<endl;
  353.    
  354.     ofs<<"[My Computer]"<<endl;
  355.     ofs<<"index=10"<<endl;
  356.     ofs<<"path=";
  357.     GetWindowsDirectory(data,MAX_PATH);
  358.     ofs<<data;
  359.     ofs<<"\\Explorer.exe"<<endl;
  360.     ofs<<"command=/E,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"<<endl;  
  361.     ofs<<"password=0"<<endl<<endl;
  362.    
  363.     ofs<<"[My Documents]"<<endl;
  364.     ofs<<"index=12"<<endl;
  365.     ofs<<"path=Explorer.exe"<<endl;
  366.     ofs<<"command=/N,::{450D8FBA-AD25-11D0-98A8-0800361B1103}"<<endl;
  367.     ofs<<"password=0"<<endl<<endl;
  368.    
  369.     ofs<<"[Control Panel]"<<endl;
  370.     ofs<<"index=13"<<endl;
  371.     ofs<<"path=";
  372.     GetWindowsDirectory(data,MAX_PATH);
  373.     ofs<<data;
  374.     ofs<<"\\explorer.exe"<<endl;
  375.     ofs<<"command=/N,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}";
  376.     ofs<<"\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}"<<endl;
  377.     ofs<<"password=0"<<endl<<endl;
  378.    
  379.     ofs<<"[Recycle Bin]"<<endl;
  380.     ofs<<"index=14"<<endl;
  381.     ofs<<"path=Explorer"<<endl;
  382.     ofs<<"command=/N,::{645FF040-5081-101B-9F08-00AA002F954E}"<<endl;
  383.     ofs<<"password=0"<<endl<<endl;
  384.    
  385.     ofs<<"[google (google chrome)]"<<endl;
  386.     ofs<<"index=11"<<endl;
  387.     ofs<<"path=";
  388.     SHGetSpecialFolderPath(0,data,CSIDL_PROGRAM_FILES,FALSE );
  389.     ofs<<data;
  390.     ofs<<"\\Google\\Chrome\\Application\\chrome.exe"<<endl;
  391.     ofs<<"command=-incognito www.google.com www.youtube.com"<<endl;
  392.     ofs<<"password=1"<<endl<<endl;
  393.     hFile = CreateFile("TrSettings.ini",GENERIC_WRITE,0, NULL, CREATE_NEW , 0, NULL);
  394.     if (hFile == INVALID_HANDLE_VALUE )
  395.      { 
  396.        DisplayError("initIniFile Create");
  397.        CloseHandle(hFile);
  398.        return;
  399.      }
  400.     result = WriteFile(hFile,ofs.str().c_str(),ofs.str().size(),&dwWritten,NULL);
  401.     if(!result)
  402.     {
  403.       DisplayError("initIniFile Write");   
  404.     }
  405.     CloseHandle(hFile);
  406.     SetFileAttributes("TrSettings.ini",FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM );
  407. }
  408.  
  409. void handleCBBSel(HWND hwnd,LPSTR arg)
  410. {
  411.   for(int k=0;k<myVec.size();k++)
  412.     {          
  413.         if(myVec[k].index.compare(arg)==0)
  414.         {
  415.              SendMessage(GetDlgItem(hwnd,116),WM_SETTEXT,0,reinterpret_cast<LPARAM>(myVec[k].name.c_str()));
  416.              SendMessage(GetDlgItem(hwnd,118),WM_SETTEXT,0,reinterpret_cast<LPARAM>(myVec[k].path.c_str()));
  417.              SendMessage(GetDlgItem(hwnd,120),WM_SETTEXT,0,reinterpret_cast<LPARAM>(myVec[k].command.c_str()));
  418.              if(myVec[k].password.compare("1")==0)
  419.                SendMessage(GetDlgItem(hwnd,121),BM_SETCHECK ,BST_CHECKED,0);
  420.              else SendMessage(GetDlgItem(hwnd,121),BM_SETCHECK ,BST_UNCHECKED,0);
  421.              return;
  422.         }
  423.     }
  424.     SendMessage(GetDlgItem(hwnd,116),WM_SETTEXT,0,0);
  425.     SendMessage(GetDlgItem(hwnd,118),WM_SETTEXT,0,0);
  426.     SendMessage(GetDlgItem(hwnd,120),WM_SETTEXT,0,0);
  427.     SendMessage(GetDlgItem(hwnd,121),BM_SETCHECK ,BST_UNCHECKED,0);
  428. }
  429. void onClickConfirm(HWND hwnd)
  430. {
  431.     char data[MAX_PATH];
  432.     int inddex;
  433.     Vv tmpVv;
  434.     int iselected =SendMessage(GetDlgItem(hwnd,113), CB_GETCURSEL , 0,0);
  435.     SendMessage(GetDlgItem(hwnd,113), CB_GETLBTEXT , iselected,reinterpret_cast<LPARAM>(buffer));
  436.    
  437.     SendMessage(GetDlgItem(hwnd,116),WM_GETTEXT,MAX_PATH,reinterpret_cast<LPARAM>(data));
  438.     tmpVv.name=data;
  439.     tmpVv.index=buffer;
  440.     SendMessage(GetDlgItem(hwnd,118),WM_GETTEXT,MAX_PATH,reinterpret_cast<LPARAM>(data));
  441.     tmpVv.path=data;
  442.     SendMessage(GetDlgItem(hwnd,120),WM_GETTEXT,MAX_PATH,reinterpret_cast<LPARAM>(data));
  443.     tmpVv.command=data;
  444.     if(BST_CHECKED==SendMessage(GetDlgItem(hwnd,121),BM_GETCHECK ,0,0))
  445.     tmpVv.password="1";
  446.     else tmpVv.password="0";
  447.    
  448.     for(int k=0;k<myVec.size();k++)
  449.     {          
  450.         if(myVec[k].index.compare(tmpVv.index)==0)
  451.         {
  452.           myVec.erase(myVec.begin()+k);
  453.         }
  454.     }
  455.     if(!tmpVv.name.size() && !tmpVv.path.size() && !tmpVv.command.size())
  456.     {
  457.        MessageBox(hwnd,"Deleted !","Settings",MB_OK);
  458.     }
  459.     else
  460.     {
  461.       myVec.push_back(tmpVv);
  462.       MessageBox(hwnd,"Done !","Settings",MB_OK);
  463.     }
  464. }
  465.  
  466. void onClickApply()
  467. {
  468.     HANDLE hFile;
  469.     DWORD dwWritten=0;
  470.     ostringstream oss;
  471.     hFile = CreateFile("TrSettings.ini",GENERIC_WRITE,0, NULL, TRUNCATE_EXISTING , 0, NULL);
  472.     if (hFile!= INVALID_HANDLE_VALUE)
  473.     {
  474.       for(int k=0;k<myVec.size();k++)
  475.       {
  476.        oss<<"["<< myVec[k].name <<"]"<<endl;
  477.        oss<<"index="<< myVec[k].index <<endl;
  478.        oss<<"path="<< myVec[k].path <<endl;
  479.        oss<<"command="<< myVec[k].command <<endl;
  480.        oss<<"password="<< myVec[k].password <<endl<<endl;
  481.        WriteFile(hFile,oss.str().c_str(),oss.str().size(),&dwWritten,NULL);
  482.        oss.clear();
  483.        oss.str(string());
  484.        }
  485.        CloseHandle(hFile);
  486.     }
  487.     SetFileAttributes("TrSettings.ini",FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM );
  488.     cls();
  489.     design();  
  490.     choices(); 
  491. }
  492.  
  493. void GetMyPath(HWND hwnd)
  494. {
  495.    char currDir[MAX_PATH];
  496.    GetCurrentDirectory(MAX_PATH,currDir);
  497.    OPENFILENAME ofn;
  498.    char szFileName[MAX_PATH];
  499.    string str;
  500.    ZeroMemory(&ofn, sizeof(ofn));
  501.    szFileName[0] = 0;
  502.    ofn.lStructSize = sizeof(ofn);
  503.    ofn.hwndOwner = hwnd;
  504.    ofn.lpstrTitle="Open file";
  505.    ofn.lpstrFilter ="All Files\0*.*\0";
  506.    ofn.nMaxFile = MAX_PATH;
  507.    ofn.lpstrFile=szFileName;
  508.    ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST ;
  509.    if( GetOpenFileName(&ofn))
  510.    {
  511.      str.assign(ofn.lpstrFile);
  512.      int pos=str.find_last_of("\\");
  513.      if(pos!=string::npos) str.erase(str.begin(),str.begin() + pos+1);
  514.      SendMessage(GetDlgItem(hwnd,116),WM_SETTEXT,0,reinterpret_cast<LPARAM>(str.c_str()));
  515.      str.assign(ofn.lpstrFile);
  516.      pos=str.find_last_of("\\");
  517.      if(pos!=string::npos) str.erase(str.begin()+ pos,str.end());
  518.      SendMessage(GetDlgItem(hwnd,118),WM_SETTEXT,0,reinterpret_cast<LPARAM>(ofn.lpstrFile));
  519.      SendMessage(GetDlgItem(hwnd,120),WM_SETTEXT,0,reinterpret_cast<LPARAM>(str.c_str()));   
  520.    }
  521.    SetCurrentDirectory(currDir);
  522. }
  523.  
  524. LRESULT CALLBACK DialogProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
  525. {
  526.   int iselected;
  527.   switch(msg)  
  528.   {
  529.     case WM_COMMAND:
  530.        switch(LOWORD(wParam))
  531.        {
  532.           case 111 :
  533.              onClickConfirm(hwnd);
  534.              SetFocus(GetDlgItem(hwnd,113));
  535.              break;
  536.           case 112 :
  537.              onClickApply();         
  538.              SendMessage(hwnd,WM_CLOSE,0,0);
  539.              break;
  540.           case 122 :
  541.              GetMyPath(hwnd);
  542.              break;              
  543.           case 1122 :        
  544.              SendMessage(hwnd,WM_CLOSE,0,0);
  545.              break;  
  546.           case 113:
  547.              switch (HIWORD(wParam))
  548.               {
  549.                  case CBN_SELCHANGE :
  550.                    iselected =SendMessage(GetDlgItem(hwnd,113), CB_GETCURSEL , 0,0);
  551.                    SendMessage(GetDlgItem(hwnd,113), CB_GETLBTEXT , iselected,reinterpret_cast<LPARAM>(buffer));
  552.                    if(BST_UNCHECKED==SendMessage(GetDlgItem(hwnd,1222),BM_GETCHECK ,0,0))
  553.                     handleCBBSel(hwnd,buffer);
  554.                    break;
  555.               }
  556.              break;  
  557.           case 121 :
  558.              if(BST_CHECKED==SendMessage(GetDlgItem(hwnd,121),BM_GETCHECK ,0,0))
  559.                 SendMessage(GetDlgItem(hwnd,121),BM_SETCHECK ,BST_UNCHECKED,0);
  560.              else SendMessage(GetDlgItem(hwnd,121),BM_SETCHECK ,BST_CHECKED,0);
  561.              break;    
  562.           case 1222 :
  563.              if(BST_CHECKED==SendMessage(GetDlgItem(hwnd,1222),BM_GETCHECK ,0,0))
  564.                 SendMessage(GetDlgItem(hwnd,1222),BM_SETCHECK ,BST_UNCHECKED,0);
  565.              else SendMessage(GetDlgItem(hwnd,1222),BM_SETCHECK ,BST_CHECKED,0);
  566.              SetFocus(GetDlgItem(hwnd,113));
  567.              break;                      
  568.        }
  569.        break;
  570.     case WM_CLOSE:
  571.         PostQuitMessage(0);
  572.         break;
  573.   }
  574.    return DefWindowProc(hwnd,msg,wParam,lParam);
  575. }
  576.  
  577. HWND CreateToolTip(int toolID, HWND hDlg, LPSTR pszText)
  578. {
  579.     if (!toolID || !hDlg || !pszText)
  580.     {
  581.         return FALSE;
  582.     }
  583.     // Get the window of the tool.
  584.     HWND hwndTool = GetDlgItem(hDlg, toolID);
  585.    
  586.     // Create the tooltip.
  587.     HWND hwndTip = CreateWindowEx(NULL, TOOLTIPS_CLASS, NULL,
  588.                               WS_POPUP |TTS_ALWAYSTIP | TTS_BALLOON,
  589.                               CW_USEDEFAULT, CW_USEDEFAULT,
  590.                               CW_USEDEFAULT, CW_USEDEFAULT,
  591.                               hDlg, NULL,
  592.                               NULL, NULL);
  593.    
  594.    if (!hwndTool || !hwndTip)
  595.    {
  596.        return (HWND)NULL;
  597.    }                              
  598.                              
  599.     // Associate the tooltip with the tool.
  600.     TOOLINFO toolInfo = { 0 };
  601.     toolInfo.cbSize = sizeof(toolInfo);
  602.     toolInfo.hwnd = hDlg;
  603.     toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
  604.     toolInfo.uId = (UINT_PTR)hwndTool;
  605.     toolInfo.lpszText = pszText;
  606.     SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo);
  607.     SendMessageW(hwndTip, TTM_SETMAXTIPWIDTH,0, (LPARAM)350);
  608.     return hwndTip;
  609. }
  610.  
  611. void CreateDialogBox()
  612. {
  613.   HINSTANCE inst = GetModuleHandle(NULL);
  614.   HWND hwnd = GetConsoleWindow();
  615.   CoInitialize(NULL);
  616.  
  617.  
  618.   WNDCLASSEX wc = {0};
  619.   wc.cbSize           = sizeof(WNDCLASSEX);
  620.   wc.lpfnWndProc      = DialogProc;
  621.   wc.hInstance        = inst;
  622.   wc.hbrBackground    = GetSysColorBrush(COLOR_3DFACE);
  623.   wc.hCursor          = LoadCursor(NULL,IDC_ARROW);
  624.   wc.lpszClassName    = TEXT("DialogClass");
  625.  
  626.   RegisterClassEx(&wc);
  627.  
  628.   RECT rect;
  629.   GetWindowRect(hwnd,&rect);
  630.   HWND hdialog = CreateWindowEx(WS_EX_DLGMODALFRAME,"DialogClass","Settings",
  631.                  WS_VISIBLE | WS_SYSMENU | WS_CAPTION , rect.left+100,
  632.                  rect.top+70, 500, 200,NULL, NULL, inst,  NULL);
  633.   CreateWindow("button","Confirm",WS_VISIBLE | WS_CHILD  | WS_TABSTOP | WS_BORDER ,90, 130, 90, 25,        
  634.                 hdialog, (HMENU) 111, NULL, NULL);
  635.   CreateWindow("button","Apply Settings",WS_VISIBLE | WS_CHILD | WS_BORDER,190, 130, 120, 25,        
  636.                 hdialog, (HMENU) 112, NULL, NULL);
  637.   CreateWindow("button","Cancel",WS_VISIBLE | WS_CHILD | WS_TABSTOP | WS_BORDER,320, 130, 90, 25,        
  638.                 hdialog, (HMENU) 1122, NULL, NULL);
  639.   CreateWindow("COMBOBOX","Index",WS_VISIBLE | WS_CHILD | WS_TABSTOP | CBS_DROPDOWNLIST
  640.                | WS_VSCROLL | WS_TABSTOP | WS_EX_LEFTSCROLLBAR,
  641.                90, 5, 100,150,hdialog, (HMENU) 113, NULL, NULL);
  642.   CreateWindow("static","Index :",WS_VISIBLE | WS_CHILD,5, 7, 50, 25,        
  643.                 hdialog, (HMENU) 114, NULL, NULL);
  644.   CreateWindow("static","Title   :",WS_VISIBLE | WS_CHILD,5, 36, 50, 25,        
  645.                 hdialog, (HMENU) 115, NULL, NULL);
  646.   CreateWindow("edit","",WS_VISIBLE | WS_CHILD |WS_BORDER | WS_TABSTOP ,90, 34, 160, 20,        
  647.                 hdialog, (HMENU) 116, NULL, NULL);  
  648.   CreateWindow("static","Path   :",WS_VISIBLE | WS_CHILD,5, 61, 50, 25,        
  649.                 hdialog, (HMENU) 117, NULL, NULL);
  650.   CreateWindow("button","...",WS_VISIBLE | WS_CHILD,445, 60, 25, 20,        
  651.                 hdialog, (HMENU) 122, NULL, NULL);         
  652.   CreateWindow("edit","",WS_VISIBLE | WS_CHILD |ES_AUTOHSCROLL |WS_BORDER | WS_TABSTOP ,90, 60, 350, 20,        
  653.                 hdialog, (HMENU) 118, NULL, NULL);  
  654.   CreateWindow("static","Command :",WS_VISIBLE | WS_CHILD,5, 81, 80, 25,        
  655.                 hdialog, (HMENU) 119, NULL, NULL);
  656.   CreateWindow("edit","",WS_VISIBLE | WS_CHILD |ES_AUTOHSCROLL |WS_BORDER | WS_TABSTOP ,90, 84, 350, 20,        
  657.                 hdialog, (HMENU) 120, NULL, NULL);
  658.   CreateWindow("button","Password :",WS_VISIBLE | WS_CHILD | BS_CHECKBOX | BS_LEFTTEXT,
  659.                 5, 104, 100, 25,hdialog, (HMENU) 121, NULL, NULL);
  660.   CreateWindow("button","change Index",WS_VISIBLE | WS_CHILD | BS_CHECKBOX ,
  661.                 195, 5, 110, 25,hdialog, (HMENU) 1222, NULL, NULL);
  662.   LPSTR pszText ="Any Title you chose";
  663.   CreateToolTip(116,hdialog,pszText);
  664.   pszText ="path to executable, for system executabes :\r\n explorer.exe \
  665.  is the same as c:\\windows\\explorer.exe";
  666.   CreateToolTip(118,hdialog,pszText);
  667.   pszText ="Command line specific for each executabe.\
  668.  \r\n explorer.exe takes the Folder Path as command line";
  669.   CreateToolTip(120,hdialog,pszText);
  670.   pszText ="change index without changing text in Title, Path And Command\
  671.  Text Fields, Hit confirm To associate the new index.";
  672.   CreateToolTip(1222,hdialog,pszText);
  673.   pszText ="To Delete an index Entry, Hit Confirm with\n\
  674.  Title, Path And Command Text Fields all empty.";
  675.   CreateToolTip(113,hdialog,pszText);
  676.  
  677.   SendMessage(GetDlgItem(hdialog,113), CB_RESETCONTENT,0,0);
  678.   for(int i=0;i<19;i++)
  679.   SendMessage(GetDlgItem(hdialog,113), CB_ADDSTRING, 0,reinterpret_cast<LPARAM>(aindex[i].c_str()) );
  680.   for(int i=0;i<20;i++)
  681.   SendMessage(GetDlgItem(hdialog,113), CB_ADDSTRING, 0,reinterpret_cast<LPARAM>(findex[i].c_str()) );  
  682.   SendMessage(GetDlgItem(hdialog,113), CB_SETCURSEL,0,0);
  683.   SendMessage(hdialog,WM_COMMAND,MAKEWPARAM(113,CBN_SELCHANGE),(LPARAM)GetDlgItem(hdialog,113));
  684.   SetFocus(GetDlgItem(hdialog,113));
  685.    
  686.   HFONT SmallFont =  CreateFont(14,0,0,0,FW_BOLD,FALSE,FALSE,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,
  687.                     CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS,TEXT("Arial"));
  688.   SendMessage (GetDlgItem(hdialog,116), WM_SETFONT, WPARAM (SmallFont), TRUE);
  689.   SendMessage (GetDlgItem(hdialog,118), WM_SETFONT, WPARAM (SmallFont), TRUE);
  690.   SendMessage (GetDlgItem(hdialog,120), WM_SETFONT, WPARAM (SmallFont), TRUE);
  691.  
  692.   SHAutoComplete(GetDlgItem(hdialog,118),SHACF_DEFAULT);
  693.   SHAutoComplete(GetDlgItem(hdialog,120),SHACF_DEFAULT);
  694.  
  695.   EnableWindow(hwnd, FALSE);
  696.   SetForegroundWindow(hdialog);
  697.  
  698.   MSG Msg;
  699.   while(GetMessage(&Msg, NULL, 0, 0))
  700.   {
  701.     if(!IsDialogMessage(hdialog, &Msg))
  702.     {
  703.       TranslateMessage(&Msg);
  704.       DispatchMessage(&Msg);
  705.     }
  706.   }
  707.   EnableWindow(hwnd,TRUE);
  708.   DestroyWindow(hdialog);
  709.   SetForegroundWindow(hwnd);
  710. }
  711.  
  712. WNDPROC wpOrigEditProc;
  713. LRESULT APIENTRY EditProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
  714. {
  715.     switch(msg)  
  716.     {
  717.       case WM_GETDLGCODE:
  718.            if(wParam == VK_RETURN ) return DLGC_WANTALLKEYS;
  719.       case WM_KEYDOWN:
  720.            if(wParam == VK_RETURN )SendMessage(GetParent(hwnd),WM_CLOSE,0,0);
  721.     }
  722.     return CallWindowProc(wpOrigEditProc, hwnd, msg,wParam, lParam);    
  723. }
  724.  
  725. char data1[MAX_PATH];
  726. char data2[MAX_PATH];
  727. LRESULT CALLBACK DialogRunProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
  728. {
  729.   switch(msg)  
  730.   {
  731.     case WM_CREATE:
  732.        break;
  733.     case WM_GETDLGCODE:
  734.          if(wParam==VK_RETURN) return DLGC_WANTALLKEYS;
  735.          break;
  736.     case WM_KEYDOWN:
  737.          if(wParam == VK_RETURN)
  738.          SendMessage(hwnd,WM_CLOSE,0,0);
  739.          break;
  740.     case WM_CLOSE:
  741.          SendMessage(GetDlgItem(hwnd,118),WM_GETTEXT,MAX_PATH,reinterpret_cast<LPARAM>(data1));
  742.          SendMessage(GetDlgItem(hwnd,120),WM_GETTEXT,MAX_PATH,reinterpret_cast<LPARAM>(data2));
  743.          if(strlen(data1) || strlen(data2)) ShellExecute(0,NULL,data1,data2,NULL,1);
  744.          PostQuitMessage(0);
  745.          break;
  746.   }
  747.    return DefWindowProc(hwnd,msg,wParam,lParam);
  748. }
  749.  
  750. void CreateRunDialogBox()
  751. {
  752.   HINSTANCE inst = GetModuleHandle(NULL);
  753.   HWND hwnd = GetConsoleWindow();
  754.   CoInitialize(NULL);
  755.  
  756.   WNDCLASSEX wc = {0};
  757.   wc.cbSize           = sizeof(WNDCLASSEX);
  758.   wc.lpfnWndProc      = DialogRunProc;
  759.   wc.hInstance        = inst;
  760.   wc.hbrBackground    = GetSysColorBrush(COLOR_3DFACE);
  761.   wc.hCursor          = LoadCursor(NULL,IDC_ARROW);
  762.   wc.lpszClassName    = TEXT("DialogRunClass");
  763.  
  764.   RegisterClassEx(&wc);
  765.  
  766.   RECT rect;
  767.   GetWindowRect(hwnd,&rect);
  768.   HWND hdialog = CreateWindowEx(WS_EX_DLGMODALFRAME,"DialogRunClass","Execute",
  769.                  WS_VISIBLE, rect.left+40,rect.top+130, 500, 100,NULL, NULL, inst,  NULL);
  770.   CreateWindow("static","Executable  :",WS_VISIBLE | WS_CHILD,2, 10, 90, 25,        
  771.                 hdialog, (HMENU) 117, NULL, NULL);     
  772.   CreateWindow("edit","",WS_VISIBLE | WS_CHILD |ES_AUTOHSCROLL |WS_BORDER | WS_TABSTOP ,95, 10, 350, 20,        
  773.                 hdialog, (HMENU) 118, NULL, NULL);  
  774.   CreateWindow("static","Command    :",WS_VISIBLE | WS_CHILD,2, 33, 90, 25,        
  775.                 hdialog, (HMENU) 119, NULL, NULL);
  776.   CreateWindow("edit","",WS_VISIBLE | WS_CHILD |ES_AUTOHSCROLL |WS_BORDER | WS_TABSTOP ,95, 35, 350, 20,        
  777.                 hdialog, (HMENU) 120, NULL, NULL);
  778.    
  779.   HFONT SmallFont =  CreateFont(14,0,0,0,FW_BOLD,FALSE,FALSE,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,
  780.                     CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS,TEXT("Arial"));
  781.   SendMessage (GetDlgItem(hdialog,118), WM_SETFONT, WPARAM (SmallFont), TRUE);
  782.   SendMessage (GetDlgItem(hdialog,120), WM_SETFONT, WPARAM (SmallFont), TRUE);
  783.  
  784.   SHAutoComplete(GetDlgItem(hdialog,118),SHACF_DEFAULT);
  785.   SHAutoComplete(GetDlgItem(hdialog,120),SHACF_DEFAULT);
  786.  
  787.   wpOrigEditProc = (WNDPROC) SetWindowLong(GetDlgItem(hdialog,118),GWL_WNDPROC, (LONG) EditProc);
  788.   wpOrigEditProc = (WNDPROC) SetWindowLong(GetDlgItem(hdialog,120),GWL_WNDPROC, (LONG) EditProc);
  789.  
  790.   EnableWindow(hwnd, FALSE);
  791.   SetForegroundWindow(hdialog);
  792.   SetFocus(GetDlgItem(hdialog,118));
  793.  
  794.   MSG Msg;
  795.   while(GetMessage(&Msg, NULL, 0, 0))
  796.   {
  797.     if(!IsDialogMessage(hdialog, &Msg))
  798.     {
  799.       TranslateMessage(&Msg);
  800.       DispatchMessage(&Msg);
  801.     }
  802.   }
  803.   EnableWindow(hwnd,TRUE);
  804.   DestroyWindow(hdialog);
  805.   SetForegroundWindow(hwnd);
  806. }
  807.  
  808. void color(DWORD d)
  809. {
  810.   SetConsoleTextAttribute(handle,d);
  811.   // 10  = FOREGROUND_GREEN | FOREGROUND_INTENSITY;
  812.   // 11  = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY;
  813.   // 12  = red
  814.   // 14  = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY
  815.   // 240 = BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY;
  816.   // 249 = blue bk white
  817. }
  818.  
  819. bool setPass(LPSTR password,bool changePass)
  820. {
  821.   char tmp[35];
  822.   char pass1[15];
  823.   char pass2[15];
  824.   int i=0;
  825.   DWORD lResult,Dwsize=33;
  826.   HKEY hkey;
  827.   lResult=RegOpenKeyEx(HKEY_CURRENT_USER,TEXT("SOFTWARE"),0,KEY_READ,&hkey);
  828.   if(ERROR_SUCCESS==lResult)
  829.   lResult=RegGetValue(hkey,TEXT("MOSAIDTERMINAL"),TEXT("TerminalPass"),RRF_RT_REG_SZ,NULL,tmp,&Dwsize);
  830.   RegCloseKey(hkey);
  831.   if(ERROR_SUCCESS==lResult)
  832.   {
  833.     if(changePass)
  834.     {
  835.       cls();
  836.       color(14);
  837.       cout<<"Enter old pass:";
  838.       i=0;
  839.       while( (pass2[i]=getch())!='\r'&& i<14 )
  840.       {
  841.         putchar('*');
  842.         i++;
  843.       }
  844.       pass2[i]='\0';
  845.       if( strcmp(tmp,pass2)==0 ) goto askpass;
  846.       else
  847.       {
  848.         color(12);
  849.         cout<<"\nwrong pass!";
  850.         color(14);
  851.         cout<<"\nContinue...";
  852.         getch();
  853.         return false;
  854.       }
  855.     }
  856.     else
  857.     {
  858.       memcpy(password,tmp,13);
  859.       return true;
  860.     }
  861.   }
  862.   else
  863.   {
  864.     if(!changePass)return false;
  865.     askpass:
  866.     i=0;
  867.     cls();
  868.     color(14);
  869.     cout<<"Enter new pass:";
  870.     while( (pass1[i]=getch())!='\r'&& i<14 )
  871.     {
  872.       putchar('*');
  873.       i++;
  874.     }
  875.     pass1[i]='\0';
  876.     i=0;
  877.     cout<<"\nConfirm new pass:";
  878.     while( (pass2[i]=getch())!='\r'&& i<14 )
  879.     {
  880.       putchar('*');
  881.       i++;
  882.     }
  883.     pass2[i]='\0';
  884.     if( strcmp(pass1,pass2)==0 )
  885.     {
  886.       HKEY hkey;
  887.       DWORD lResult,Dwsize=13;
  888.       lResult=RegCreateKeyEx(HKEY_CURRENT_USER,TEXT("SOFTWARE\\MOSAIDTERMINAL"),
  889.                               0,NULL,0,KEY_ALL_ACCESS,NULL,&hkey,NULL);
  890.       lResult=RegSetValueEx(hkey,TEXT("TerminalPass"),0,REG_SZ,(BYTE*)pass1,13);
  891.       RegCloseKey(hkey);
  892.       if(ERROR_SUCCESS==lResult)
  893.       {
  894.         color(10);
  895.         cout<<"\nSuccess...";
  896.         memcpy(password,pass1,13);
  897.         color(14);
  898.         cout<<"\nContinue...";
  899.         getch();
  900.         return true;
  901.       }
  902.     }
  903.     else goto askpass;
  904.   }
  905.   return false;
  906. }
  907.  
  908. bool fpassword(LPSTR password)
  909. {
  910.     gotoxy(46,4);
  911.     color(12);
  912.     bool b=0;
  913.     char pass[15];
  914.     int i=0;
  915.     while( (pass[i]=getch())!='\r'&& i<14 )
  916.     {
  917.       putchar('*');
  918.       i++;
  919.     }
  920.     pass[i]='\0';
  921.     if( strcmp(pass,password)==0 )b=1;
  922.     else{
  923.        gotoxy(38,5);
  924.        cout<<"wrong password.";
  925.        getch();
  926.     }
  927.     return b;
  928. }
  929. int mdays(int m,int y)
  930. {
  931.   if(m==2)
  932.        if(y%4==0 && y%100!=0 || y%400==0) return 29;
  933.        else return 28;
  934.   else
  935.       if(m%2==0 && m<=7 || m%2!=0 && m>7) return 30;
  936.       else return 31;
  937. }
  938. int st(int m_day,int day_i)
  939. {
  940.   while(m_day>1)
  941.   {  
  942.     m_day--;
  943.     day_i--;
  944.     if(day_i<0) day_i=6;
  945.   }
  946.   return day_i;
  947. }
  948. void printDate(void)
  949. {
  950.         time_t t = time(0);
  951.         struct tm * now_t = localtime(&t);
  952.         char  buf[80];
  953.         strftime(buf, sizeof(buf), "%Y/%m/%d  %X",now_t);      
  954.         int year    = now_t->tm_year;
  955.         int month   = now_t->tm_mon+1;
  956.         int day_m   = now_t->tm_mday;
  957.         int day_i   = now_t->tm_wday;
  958.         int m_days  = mdays(month,year);
  959.         day_i = st(day_m,day_i);
  960.         gotoxy(35,18);
  961.         cout<<buf;
  962.         int a =1;  
  963.         gotoxy(30,20);
  964.         color(14);
  965.         printf("  Su  Mo  Tu  We  Th  Fr  Sa  ");  
  966.         color(11);
  967.         for(int i=0;i<=5;i++)
  968.         {
  969.          gotoxy(30,22 + i);
  970.          for(int j=0;j<7;j++)
  971.           {          
  972.             if(i==0 && j<day_i) printf("    ");
  973.             else
  974.             {
  975.               if(a == day_m)
  976.               {
  977.                 color(12); 
  978.                 printf("%4d",a);
  979.                 color(11);
  980.               }
  981.               if(a<=m_days && a != day_m)printf("%4d",a);
  982.               a++;
  983.             }
  984.           }      
  985.         }
  986. }
  987.  
  988. void parse(string& arg)
  989. {
  990.     if(arg.compare("ss")==0 || arg.compare("SS")==0)
  991.     {
  992.         CreateDialogBox();
  993.         return;
  994.     }
  995.     if(arg.compare("rr")==0 || arg.compare("RR")==0)
  996.     {
  997.         CreateRunDialogBox();
  998.         return;
  999.     }
  1000.     if(arg.compare("xx")==0  || arg.compare("XX")==0)
  1001.     {
  1002.         exit(0);
  1003.         return;
  1004.     }
  1005.     if(arg.compare("aa")==0  || arg.compare("AA")==0)
  1006.     {    
  1007.         cls();
  1008.         color(10);
  1009.         cout<<"\n "<<char(4)<<" FEATUTRES:\n\n";
  1010.         color(11);
  1011.         cout<<"     "<<char(16)<<" Quick access to Files and Folders.\n";
  1012.         cout<<"     "<<char(16)<<" Quick access to play-lists and videos.\n";
  1013.         cout<<"     "<<char(16)<<" Quick access to Anything you want.\n";
  1014.         cout<<"     "<<char(16)<<" Windows's Run Command.\n";
  1015.         cout<<"     "<<char(16)<<" Prevent screen saver and display off.\n";
  1016.         cout<<"     "<<char(16)<<" Mouse Double Click to execute .\n\n";
  1017.         color(10);
  1018.         cout<<"\n "<<char(4)<<" ABOUT:\n\n";
  1019.         color(11);
  1020.         cout<<"     E-Mail : mosaid_radouan@yahoo.fr \n";
  1021.         cout<<"     C 2015 By MOSAID.\n\n";
  1022.         printDate();
  1023.         gotoxy(0,16);
  1024.         color(12);
  1025.         cout<<" "<<char(4)<<" Continue...";
  1026.         getch();       
  1027.         cls();
  1028.         design();  
  1029.         choices();
  1030.         return;
  1031.     }
  1032.     if(arg.compare("pp")==0 || arg.compare("PP")==0)
  1033.     {
  1034.         char password[15];
  1035.         char cara;
  1036.         cls();
  1037.         color(14);
  1038.         cout<<"Change pass ? (y/n):";
  1039.         cara=getch();
  1040.         if(cara =='y' || cara == 'Y' )setPass(password,true);
  1041.         cls();
  1042.         design();  
  1043.         choices();
  1044.         return;
  1045.     }
  1046.     if(arg.compare("mm")==0 || arg.compare("MM")==0)
  1047.     {
  1048.         HWND hwnd = GetConsoleWindow();
  1049.         ShowWindow(hwnd,SW_MINIMIZE);
  1050.         return;
  1051.     }
  1052.     for(int k=0;k<myVec.size();k++)
  1053.       {      
  1054.            if(myVec[k].index.compare(arg)==0)
  1055.            {
  1056.              if(myVec[k].password.compare("1")==0)
  1057.              {         
  1058.                 char passwd[15];
  1059.                 if(!setPass(passwd,false))
  1060.                 {
  1061.                   gotoxy(38,5);
  1062.                   color(12);
  1063.                   cout<<"password not set.";
  1064.                   getch();
  1065.                   return;
  1066.                 }              
  1067.                 if(!fpassword(passwd)) return;
  1068.              }
  1069.              ShellExecute(0,NULL,myVec[k].path.c_str(),myVec[k].command.c_str(),NULL,1);
  1070.              return;
  1071.            }
  1072.       }
  1073. }
  1074.  
  1075. void cls()
  1076.  {
  1077.     color(0);
  1078.     HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE );
  1079.     CONSOLE_SCREEN_BUFFER_INFO csbi;
  1080.     DWORD dwConSize;                
  1081.     GetConsoleScreenBufferInfo( hConsole, &csbi );
  1082.     dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
  1083.     gotoxy(0,0);
  1084.     for( int i=0;i<dwConSize;i++)cout<<' ';
  1085.     gotoxy(0,0);
  1086.  }
  1087.    
  1088. void DisplayError(LPCSTR lpszFunction)
  1089. {
  1090.     // Retrieve the system error message for the last-error code
  1091.  
  1092.     LPVOID lpMsgBuf;
  1093.     LPVOID lpDisplayBuf;
  1094.     DWORD dw = GetLastError();
  1095.  
  1096.     FormatMessage(
  1097.         FORMAT_MESSAGE_ALLOCATE_BUFFER |
  1098.         FORMAT_MESSAGE_FROM_SYSTEM |
  1099.         FORMAT_MESSAGE_IGNORE_INSERTS,
  1100.         NULL,
  1101.         dw,
  1102.         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
  1103.         (LPTSTR) &lpMsgBuf,
  1104.         0, NULL );
  1105.  
  1106.     // Display the error message and exit the process
  1107.  
  1108.     lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT,
  1109.         (lstrlen((LPCTSTR)lpMsgBuf) + lstrlen((LPCTSTR)lpszFunction) + 40) * sizeof(TCHAR));
  1110.     StringCchPrintf((LPTSTR)lpDisplayBuf,
  1111.         LocalSize(lpDisplayBuf) / sizeof(TCHAR),
  1112.         TEXT("%s failed with error %d: %s"),
  1113.         lpszFunction, dw, lpMsgBuf);
  1114.     MessageBox(NULL, (LPCTSTR)lpDisplayBuf, TEXT("Error"), MB_OK);
  1115.  
  1116.     LocalFree(lpMsgBuf);
  1117.     LocalFree(lpDisplayBuf);
  1118. }
  1119.  
  1120. int BringWToTop(void)
  1121. {
  1122.     PROCESSENTRY32 entry;
  1123.     entry.dwSize = sizeof(PROCESSENTRY32);
  1124.     HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
  1125.     if (Process32First(snapshot, &entry) == TRUE)
  1126.     {
  1127.         while (Process32Next(snapshot, &entry) == TRUE)
  1128.         {
  1129.             if (stricmp(entry.szExeFile, "target.exe") == 0)
  1130.             {  
  1131.                 HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, entry.th32ProcessID);
  1132.                 //SetForegroundWindow(
  1133.                 CloseHandle(hProcess);
  1134.             }
  1135.         }
  1136.     }
  1137.     CloseHandle(snapshot);
  1138.     return 0;
  1139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement