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

📄 wredde.c

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************
*
*                            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 <windows.h>
#include <ddeml.h>

#include "wreglbl.h"
#include "wresall.h"
#include "wreres.h"
#include "wregcres.h"
#include "wresrvr.h"
#include "wremem.h"
#include "wredlg.h"
#include "wredde.h"
#include "wreimg.h"

/****************************************************************************/
/* macro definitions                                                        */
/****************************************************************************/
#define NUM_SERVERS     4
#define NUM_TOPICS      4
#define TIME_OUT        4000
#define LONG_TIME_OUT   0x7fffffff

/****************************************************************************/
/* external function prototypes                                             */
/****************************************************************************/
extern HDDEDATA WINEXPORT DdeCallBack( WORD wType, WORD wFmt, HCONV hConv,
                                      HSZ hsz1, HSZ hsz2, HDDEDATA hdata,
                                      DWORD lData1, DWORD lData2 );

/****************************************************************************/
/* static function prototypes                                               */
/****************************************************************************/

/****************************************************************************/
/* type definitions                                                         */
/****************************************************************************/
typedef struct WREServer {
    char        *service;
    char        *topic;
    HSZ         hservice;
    HSZ         htopic;
} WREServer;

typedef struct WRETopic {
    char        *topic;
    HSZ         htopic;
} WRETopic;

/****************************************************************************/
/* static variables                                                         */
/****************************************************************************/
static  WREServer       EditServers[NUM_SERVERS] =
{
    { WDE_SERVICE_NAME, WDE_SERVICE_TOPIC, NULL, NULL },
    { BMP_SERVICE_NAME, BMP_SERVICE_TOPIC, NULL, NULL },
    { CUR_SERVICE_NAME, CUR_SERVICE_TOPIC, NULL, NULL },
    { ICO_SERVICE_NAME, ICO_SERVICE_TOPIC, NULL, NULL }
};

static  WRETopic        Topics[NUM_TOPICS] =
{
    { WRE_DIALOG_TOPIC, NULL },
    { WRE_BITMAP_TOPIC, NULL },
    { WRE_CURSOR_TOPIC, NULL },
    { WRE_ICON_TOPIC,   NULL }
};

static  DWORD           IdInst                  = 0;
static  FARPROC         DdeProc                 = NULL;
static  HSZ             hServiceName            = NULL;
static  HSZ             hFileItem               = NULL;
static  HSZ             hIs32BitItem            = NULL;
static  HSZ             hNameItem               = NULL;
static  HSZ             hDataItem               = NULL;
static  HSZ             hDialogDump             = NULL;
static  HSZ             hImageDump              = NULL;
static  WRESPT          PendingService          = NoServicePending;

WRESPT WREGetPendingService( void )
{
    return( PendingService );
}

void WRESetPendingService( WRESPT s )
{
    PendingService = s;
}

Bool WREHData2Mem( HDDEDATA hData, void **data, uint_32 *size )
{
    if( !data || !size || ( hData == (HDDEDATA)NULL ) ) {
        return( FALSE );
    }

    *size = (int)DdeGetData( hData, NULL, 0, 0 );
    if( *size == 0 ) {
        return( FALSE );
    }

    *data = WREMemAlloc( *size );
    if( *data == NULL ) {
        return( FALSE );
    }

    if( (DWORD)(*size) != DdeGetData( hData, *data, (DWORD)*size, 0 ) ) {
        WREMemFree( *data );
        return( FALSE );
    }

    return( TRUE );
}

Bool WREDDEStart( HINSTANCE inst )
{
    WORD        ret;
    DWORD       flags;
    int         i;

    _wre_touch(inst); /* MakeProcInstance vanishes in NT */

    if( IdInst != 0 ) {
        return( FALSE );
    }

    DdeProc = MakeProcInstance( (FARPROC)DdeCallBack, inst );
    if( DdeProc == (FARPROC)NULL ) {
        return( FALSE );
    }

    flags = APPCLASS_STANDARD | APPCMD_FILTERINITS |
                CBF_FAIL_ADVISES | CBF_FAIL_SELFCONNECTIONS |
                CBF_SKIP_REGISTRATIONS | CBF_SKIP_UNREGISTRATIONS;

    ret = DdeInitialize( &IdInst, (PFNCALLBACK)DdeProc, flags, 0 );
    if( ret != DMLERR_NO_ERROR ) {
        return( FALSE );
    }

    for( i=0; i<NUM_SERVERS;i++ ) {
        EditServers[i].htopic = DdeCreateStringHandle( IdInst, EditServers[i].topic, CP_WINANSI );
        if( EditServers[i].htopic == (HSZ)NULL ) {
            return( FALSE );
        }
        EditServers[i].hservice = DdeCreateStringHandle( IdInst, EditServers[i].service, CP_WINANSI );
        if( EditServers[i].hservice == (HSZ)NULL ) {
            return( FALSE );
        }
    }

    for( i=0; i<NUM_TOPICS;i++ ) {
        Topics[i].htopic = DdeCreateStringHandle( IdInst, Topics[i].topic, CP_WINANSI );
        if( Topics[i].htopic == (HSZ)NULL ) {
            return( FALSE );
        }
    }

    hDialogDump = DdeCreateStringHandle( IdInst, WRE_DIALOG_DUMP, CP_WINANSI );
    if( hDialogDump == (HSZ)NULL ) {
        return( FALSE );
    }

    hImageDump = DdeCreateStringHandle( IdInst, WRE_IMAGE_DUMP, CP_WINANSI );
    if( hImageDump == (HSZ)NULL ) {
        return( FALSE );
    }

    hServiceName = DdeCreateStringHandle( IdInst, WRE_SERVICE_NAME, CP_WINANSI );
    if( hServiceName == (HSZ)NULL ) {
        return( FALSE );
    }

    hFileItem = DdeCreateStringHandle( IdInst, WRE_FILE_ITEM, CP_WINANSI );
    if( hFileItem == (HSZ)NULL ) {
        return( FALSE );
    }

    hIs32BitItem = DdeCreateStringHandle( IdInst, WRE_32BIT_ITEM, CP_WINANSI );
    if( hIs32BitItem == (HSZ)NULL ) {
        return( FALSE );
    }

    hDataItem = DdeCreateStringHandle( IdInst, WRE_DATA_ITEM, CP_WINANSI );
    if( hDataItem == (HSZ)NULL ) {
        return( FALSE );
    }

    hNameItem = DdeCreateStringHandle( IdInst, WRE_NAME_ITEM, CP_WINANSI );
    if( hNameItem == (HSZ)NULL ) {
        return( FALSE );
    }

    DdeNameService( IdInst, hServiceName, (HSZ)NULL, DNS_REGISTER );

    return( TRUE );
}

void WREDDEEnd( void )
{

⌨️ 快捷键说明

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