Annotation of q_a/samples/guigrep/ntgrep.c, revision 1.1

1.1     ! root        1: /****************************************************************************
        !             2: 
        !             3:     PROGRAM: NTGREP.C
        !             4: 
        !             5:     PURPOSE: Installation application for the search browse file manager extension
        !             6: 
        !             7:     FUNCTIONS:
        !             8: 
        !             9: 
        !            10: ****************************************************************************/
        !            11: 
        !            12: #include <windows.h>
        !            13: #include <string.h>
        !            14: #include "ntgrep.h"
        !            15: 
        !            16: HINSTANCE hInst;
        !            17: 
        !            18: 
        !            19: #define INITCLASSNAME "SearchInitClass"
        !            20: 
        !            21: LONG APIENTRY MainWndProc(
        !            22:        HWND hWnd,
        !            23:        UINT message,
        !            24:        UINT wParam,
        !            25:        LONG lParam);
        !            26: 
        !            27: 
        !            28: BOOL APIENTRY About(
        !            29:        HWND hDlg,
        !            30:        UINT message,
        !            31:        UINT wParam,
        !            32:        LONG lParam);
        !            33: 
        !            34: BOOL InitApplication(HINSTANCE hInstance);
        !            35: BOOL InitInstance(
        !            36:     HINSTANCE          hInstance,
        !            37:     int             nCmdShow);
        !            38: 
        !            39: 
        !            40: int PASCAL WinMain(
        !            41:     HINSTANCE hInstance,
        !            42:     HINSTANCE hPrevInstance,
        !            43:     LPSTR lpCmdLine,
        !            44:     int nCmdShow
        !            45:     )
        !            46: {
        !            47: 
        !            48:     MSG msg;
        !            49: 
        !            50:     UNREFERENCED_PARAMETER( lpCmdLine );
        !            51: 
        !            52:     if (!hPrevInstance)
        !            53:        if (!InitApplication((HINSTANCE)hInstance))
        !            54:            return (FALSE);
        !            55: 
        !            56: 
        !            57:     if (!InitInstance((HINSTANCE)hInstance, nCmdShow))
        !            58:        return (FALSE);
        !            59: 
        !            60: 
        !            61:     while (GetMessage(&msg,NULL,0,0))
        !            62:        {
        !            63:        TranslateMessage(&msg);
        !            64:        DispatchMessage(&msg);
        !            65:     }
        !            66:     return (msg.wParam);
        !            67: }
        !            68: 
        !            69: 
        !            70: 
        !            71: BOOL InitApplication(HINSTANCE hInstance)
        !            72: {
        !            73:     WNDCLASS  wc;
        !            74:     wc.style = 0;
        !            75:     wc.lpfnWndProc = (WNDPROC)MainWndProc;
        !            76: 
        !            77:     wc.cbClsExtra = 0;
        !            78:     wc.cbWndExtra = 0;
        !            79:     wc.hInstance = hInstance;
        !            80:     wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
        !            81:     wc.hCursor = LoadCursor(NULL, IDC_ARROW);
        !            82:     wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
        !            83:     wc.lpszMenuName =  "GrepMenu";
        !            84:     wc.lpszClassName = INITCLASSNAME;
        !            85: 
        !            86:     return (RegisterClass(&wc));
        !            87: 
        !            88: }
        !            89: 
        !            90: 
        !            91: BOOL InitInstance(HINSTANCE hInstance,int nCmdShow)
        !            92: {
        !            93:     HWND            hWnd;
        !            94: 
        !            95: 
        !            96:     hInst = hInstance;
        !            97: 
        !            98:     hWnd = CreateWindow(
        !            99:        INITCLASSNAME,
        !           100:        "File Search Installer",
        !           101:        WS_OVERLAPPEDWINDOW,
        !           102:        CW_USEDEFAULT,
        !           103:        CW_USEDEFAULT,
        !           104:        CW_USEDEFAULT,
        !           105:        CW_USEDEFAULT,
        !           106:        NULL,
        !           107:        NULL,
        !           108:        hInstance,
        !           109:        NULL
        !           110:     );
        !           111: 
        !           112: 
        !           113: 
        !           114:     if (!hWnd)
        !           115:        return (FALSE);
        !           116: 
        !           117: 
        !           118:     ShowWindow(hWnd, nCmdShow);
        !           119:     UpdateWindow(hWnd);
        !           120:     return (TRUE);
        !           121: 
        !           122: }
        !           123: 
        !           124: 
        !           125: LONG APIENTRY MainWndProc(
        !           126:        HWND hWnd,
        !           127:        UINT message,
        !           128:        UINT wParam,
        !           129:        LONG lParam)
        !           130: {
        !           131: 
        !           132:     switch (message) {
        !           133:        case WM_COMMAND:
        !           134:            switch (LOWORD(wParam))
        !           135:            { static char szDirBuff[MAX_PATH+12];
        !           136:              case IDM_INSTALL:
        !           137:                   GetSystemDirectory(szDirBuff,MAX_PATH);
        !           138:                   strcat(szDirBuff,"\\guigrep.dll");
        !           139:                   if (!CopyFile("guigrep.dll",szDirBuff,FALSE))
        !           140:                    { MessageBox(hWnd,"Error copying file to system directory",
        !           141:                                          "Grep setup",MB_OK);
        !           142:                          break;
        !           143:                        };
        !           144:                        WritePrivateProfileString("AddOns","File Grepper",
        !           145:                                                  "guigrep.dll","winfile.ini");
        !           146:           DialogBox(hInst,"ExplainBox",hWnd,(DLGPROC)About);
        !           147:                  /* Fall through... (vanity) */
        !           148:              case IDM_ABOUT:
        !           149:                   DialogBox(hInst,"AboutBox",hWnd,(DLGPROC)About);
        !           150:                   break;
        !           151:                  case IDM_UNINSTALL:
        !           152:                        WritePrivateProfileString("AddOns","File Grepper",
        !           153:                                                  "","winfile.ini");
        !           154:                        break;
        !           155: 
        !           156:            default:
        !           157:                    return (DefWindowProc(hWnd, message, wParam, lParam));
        !           158:            };
        !           159:            break;
        !           160:        case WM_DESTROY:
        !           161:            PostQuitMessage(0);
        !           162:            break;
        !           163: 
        !           164:        default:
        !           165:            return (DefWindowProc(hWnd, message, wParam, lParam));
        !           166:     }
        !           167:     return (0);
        !           168: }
        !           169: 
        !           170: 
        !           171: BOOL APIENTRY About(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
        !           172: {
        !           173:     switch (message) {
        !           174:        case WM_INITDIALOG:
        !           175:            return (TRUE);
        !           176: 
        !           177:        case WM_COMMAND:
        !           178:            if (LOWORD(wParam) == IDOK
        !           179:                || LOWORD(wParam) == IDCANCEL) {
        !           180:                EndDialog(hDlg, TRUE);
        !           181:                return (TRUE);
        !           182:            }
        !           183:            break;
        !           184:     }
        !           185:     return (FALSE);
        !           186:        UNREFERENCED_PARAMETER(lParam);
        !           187: }
        !           188: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.