⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spy.c

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 C
字号:
/****************************************************************************
*
*                            Open Watcom Project
*
*    Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
*  ========================================================================
*
*    This file contains Original Code and/or Modifications of Original
*    Code as defined in and that are subject to the Sybase Open Watcom
*    Public License version 1.0 (the 'License'). You may not use this file
*    except in compliance with the License. BY USING THIS FILE YOU AGREE TO
*    ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
*    provided with the Original Code and Modifications, and is also
*    available at www.sybase.com/developer/opensource.
*
*    The Original Code and all software distributed under the License are
*    distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
*    EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
*    ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
*    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
*    NON-INFRINGEMENT. Please see the License for the specific language
*    governing rights and limitations under the License.
*
*  ========================================================================
*
* Description:  WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
*               DESCRIBE IT HERE!
*
****************************************************************************/


#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include "spy.h"

extern WORD _STACKLOW;

/*
 * spyInit - initialization
 */
static BOOL spyInit( HANDLE currinst, HANDLE previnst, int cmdshow )
{
    WNDCLASS    wc;
    HANDLE      memhdl;
    WORD        i;

    i=i;
    memhdl = memhdl;    /* shut up the compiler for non-NT version */
    JDialogInit();
    Instance = currinst;
    ResInstance = currinst;
    if( !InitGblStrings() ) {
        return( FALSE );
    }
    SpyMenu = LoadMenu( ResInstance, "SPYMENU" );
    _STACKLOW = 0;
    MemStart();

    HandleMessageInst = MakeProcInstance( (FARPROC) HandleMessage, Instance );
    HintWndInit( Instance, NULL, 0 );


    /*
     * set up window class
     */
    if( !previnst ) {
        wc.style = 0L;
        wc.lpfnWndProc = (LPVOID) SpyWindowProc;
        wc.cbClsExtra = 0;
        wc.cbWndExtra = sizeof( DWORD );
        wc.hInstance = Instance;
        wc.hIcon = LoadIcon( ResInstance, "APPLICON" );
        wc.hCursor = LoadCursor( (HANDLE) NULL, IDC_ARROW);
        wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
        wc.lpszMenuName = NULL;
        wc.lpszClassName = SPY_CLASS_NAME;
        if( !RegisterClass( &wc ) ) return( FALSE );

        wc.style = CS_DBLCLKS;
        wc.lpfnWndProc = (LPVOID) SpyPickProc;
        wc.cbClsExtra = 0;
        wc.cbWndExtra = 0;
        wc.hInstance = Instance;
        wc.hIcon = LoadIcon( ResInstance, "SPYICON" );
        wc.hCursor = LoadCursor( (HANDLE) NULL, IDC_ARROW);
        wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
        wc.lpszMenuName = NULL;
        wc.lpszClassName = SpyPickClass;
        if( !RegisterClass( &wc ) ) return( FALSE );
#ifdef USE_SNAP_WINDOW
        if( !RegisterSnapClass( Instance ) ) return( FALSE );
#endif
    }

#ifndef NOUSE3D
    Ctl3dRegister( Instance );
    Ctl3dAutoSubclass( Instance );
#endif

    /*
     * now make the main window
     */
    LoadSpyConfig( NULL );
    SpyMainWindow = CreateWindow(
        SPY_CLASS_NAME,     /* Window class name */
        SpyName,            /* Window caption */
        WS_OVERLAPPEDWINDOW,  /* Window style */
        SpyMainWndInfo.xpos,  /* initial x position */
        SpyMainWndInfo.ypos,  /* initial y position */
        SpyMainWndInfo.xsize, /* initial x size */
        SpyMainWndInfo.ysize, /* initial y size */
        (HWND) NULL,        /* Parent window handle */
        (HMENU) SpyMenu,    /* Window menu handle */
        Instance,           /* Program instance handle */
        NULL);              /* Create parameters */

    if( SpyMainWindow == NULL ) {
        return( FALSE );
    }
    MyTask = GetWindowTask( SpyMainWindow );

    ShowWindow( SpyMainWindow, cmdshow );
    UpdateWindow( SpyMainWindow );

    InitMessages();
    return( TRUE );

} /* spyInit */

/*
 * SpyFini - cleanup at end
 */
void SpyFini( void )
{

#ifndef NOUSE3D
    Ctl3dUnregister( Instance );
#endif
    ClearFilter();
    SpyLogClose();
    SaveSpyConfig( NULL );
    JDialogFini();
} /* SpyFini */

/*
 * WinMain - main entry point
 */
int WINMAINENTRY WinMain( HINSTANCE currinst, HINSTANCE previnst, LPSTR cmdline, int cmdshow)
{
    MSG         msg;
    HWND        prev_hwnd;
    char        *errstr;

    cmdline = cmdline;
    errstr = errstr;
    SetInstance( currinst );
#ifdef __NT__

    /* because of the shared memory used by the NT spy we can only allow
     * one spy to exist at a time */

    prev_hwnd = FindWindow( SPY_CLASS_NAME, NULL );
    if( prev_hwnd != NULL ) {
        errstr = GetRCString( STR_ONLY_1_SPY_ALLOWED );
        MessageBox( NULL, errstr, SpyName, MB_OK | MB_ICONEXCLAMATION );

        /* setting the window topmost then not topmost is a kludge to
         * make sure the window is really moved to the top */

        SetWindowPos( prev_hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
        SetWindowPos( prev_hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
        exit(0);
    }
#else
    prev_hwnd = prev_hwnd;
#endif
    if( !spyInit( currinst, previnst, cmdshow ) ) exit( 0 );

    while( GetMessage( &msg, (HWND) NULL, 0, 0 ) ) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    SpyFini();
    return( 1 );

} /* WinMain */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -