Ignore:
Timestamp:
Jun 18, 2009, 6:27:45 PM (16 years ago)
Author:
ydario
Message:

Minor updates, backout imm changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/win16ldr/odin.c

    r5979 r21308  
    1 #ifndef MSC6
     1#ifdef WATCOMC
    22#include <windows.h>
    33#else
    44#include "msc60win.h"
    55#endif
     6//#include <ddeml.h>
    67#include <stdlib.h>
    78#include <string.h>
     
    1920HANDLE hModule = 0;
    2021
     22typedef void (FAR * PASCAL FUNC_SetPELdr)(LPCSTR);
     23
     24#ifdef DDE_COMM
     25HDDEDATA CALLBACK MyDdeCallback(UINT wType, UINT wFmt, HCONV hConv, HSZ hsz1, HSZ hsz2, HDDEDATA hData, DWORD dwData1, DWORD dwData2);
     26
     27DWORD idInst = 0;
     28HSZ   hszServer = 0, hszTopic = 0;
     29
     30#define MSG_DDE_WILDCONNECT     WM_USER+1
     31#define MSG_DDE_CONNECT         WM_USER+2
     32#endif
    2133
    2234//*****************************************************************************************
     
    2537{
    2638    MSG msg;
     39        FUNC_SetPELdr pfnSetPELdr;
     40        char  szPEPath[260];
     41        LPSTR tmp;
     42                                       
     43        hDll = LoadLibrary("odindll.dll");
     44        if(hDll == 0) {
     45                return 0;
     46        }
     47
     48        pfnSetPELdr = (FUNC_SetPELdr)GetProcAddress(hDll, "SETPELDR");
     49        if(pfnSetPELdr == NULL) {
     50                return 0;
     51        }                 
     52        //check if the caller specified the path of the PE loader; if so, pass
     53        //it on to odindll
     54    tmp = strstr(lpCmdLine, "/PELDR=[");
     55    if(tmp) {
     56        tmp += 8;       //skip /peldr=[
     57        strcpy(szPEPath, tmp);
     58        tmp = szPEPath;
     59       
     60        while(*tmp != ']' && *tmp != 0) tmp++;
     61       
     62        if(*tmp == ']') {
     63                *tmp = 0;
     64                pfnSetPELdr(szPEPath);
     65        }               
     66       
     67        //now skip this parameter               
     68        tmp = strstr(lpCmdLine, "/PELDR=[");
     69        while(*tmp != ']' && *tmp != 0) tmp++;     
     70        if(*tmp == ']') {
     71                tmp++;
     72        }
     73                lpCmdLine = tmp;       
     74    }
    2775
    2876    if (!hPrevInstance)
     
    3280    if (!InitInstance(hInstance, nCmdShow))
    3381        return (FALSE);
     82
     83#ifdef DDE_COMM
     84    if(DdeInitialize(&idInst, MyDdeCallback, APPCLASS_STANDARD, 0) != DMLERR_NO_ERROR) {
     85        return FALSE;
     86    }
     87    hszServer = DdeCreateStringHandle(idInst, "Win16OdinServer", CP_WINANSI);
     88    if(hszServer == 0) {
     89        return FALSE;
     90    }
     91    hszTopic = DdeCreateStringHandle(idInst, "Win16Broadcast", CP_WINANSI);
     92    if(hszTopic == 0) {
     93        return FALSE;
     94    }
     95    if(DdeNameService(idInst, hszServer, 0, DNS_REGISTER) == 0) {
     96        return FALSE;
     97    }
     98#endif
    3499
    35100    while(*lpCmdLine == ' ') lpCmdLine++;
     
    48113               
    49114                sprintf(errormsg, "WinExec %s failed with error %d", lpCmdLine, hModule);
    50                 MessageBox(hwnd, errormsg, "Ïnternal Error", MB_ICONHAND);
     115                MessageBox(hwnd, errormsg, "Internal Error", MB_ICONHAND);
    51116                DestroyWindow(hwnd);
    52117        }
    53118               
     119#ifdef DDE_COMM
     120    DdeNameService(idInst, hszServer, 0, DNS_UNREGISTER);               
     121    DdeFreeStringHandle(idInst, hszServer);
     122    DdeFreeStringHandle(idInst, hszTopic);
     123    DdeUninitialize(idInst);
     124#endif
    54125        FreeLibrary(hDll);
    55126    return (msg.wParam);
     
    60131{
    61132        WNDCLASS wc;
    62        
    63         hDll = LoadLibrary("odindll.dll");
    64         if(hDll == 0) {
    65                 return 0;
    66         }
    67133       
    68134    wc.style = NULL;
     
    88154        "Win16OdinClass",
    89155        "Odin Win16 Program Launcher",
     156#if 1
     157                WS_POPUP,
     158#else       
    90159        WS_OVERLAPPEDWINDOW | WS_VISIBLE,
     160#endif       
    91161        CW_USEDEFAULT,
    92162        CW_USEDEFAULT,
     
    127197            break;
    128198
     199#ifdef DDE_COMM
     200        case MSG_DDE_WILDCONNECT:
     201            break;
     202        case MSG_DDE_CONNECT:
     203            MessageBox(0, "MyDdeCallback", "WILDCONNECT", MB_OK);
     204            break;
     205#endif
    129206        default:
    130207            return (DefWindowProc(hWnd, message, wParam, lParam));
     
    132209    return (NULL);
    133210}
    134 //*****************************************************************************************
    135 //*****************************************************************************************
     211#ifdef DDE_COMM
     212//*****************************************************************************************
     213//*****************************************************************************************
     214HDDEDATA CALLBACK MyDdeCallback(UINT wType, UINT wFmt, HCONV hConv,
     215                                HSZ hszTopic,  HSZ hszItem,
     216                                HDDEDATA hData, DWORD dwData1, DWORD dwData2)
     217{
     218//    WORD i, j;
     219//    WORD cItems, iFmt;
     220//    HDDEDATA hDataRet;
     221
     222    char msg[128];
     223
     224////     MessageBeep(500);
     225//    sprintf(msg, "type=%x format=%x %x %x %x %x %x %x", wType, wFmt, hConv, hszTopic, hszItem, hData, dwData1, dwData2);
     226//    MessageBox(0, "MyDdeCallback", "test", MB_OK);
     227
     228    if(wType == XTYP_EXECUTE && wFmt == CF_TEXT)
     229    {
     230        char szExec[64];
     231
     232        DdeGetData(hData, (LPBYTE)szExec, 64, 0);
     233        szExec[63] = 0;
     234        MessageBox(0, "MyDdeCallback", szExec, MB_OK);
     235        return (HDDEDATA)TRUE;
     236    }
     237    /*
     238     * Process wild initiates here
     239     */
     240    if (wType == XTYP_WILDCONNECT) {
     241        HSZ ahsz[(1 + 1) * 2];
     242        /*
     243         * He wants a hsz list of all our available app/topic pairs
     244         * that conform to hszTopic and hszItem(App).
     245         */
     246
     247//        MessageBox(0, "MyDdeCallback", "WILDCONNECT", MB_OK);
     248
     249//        if (!ValidateContext((PCONVCONTEXT)lData1)) {
     250//            return(FALSE);
     251//        }
     252
     253        if (hszItem != hszServer && hszItem != 0) {
     254            // we only support the hszAppName service
     255            return(0);
     256        }
     257
     258        ahsz[0] = hszServer;
     259        ahsz[1] = hszTopic;
     260        // cap off the list with 0s
     261        ahsz[2] = ahsz[3] = 0L;
     262
     263        // send it back
     264        return(DdeCreateDataHandle(idInst, (LPBYTE)&ahsz[0], sizeof(HSZ) * 4, 0L, 0, wFmt, 0));
     265    }
     266    return 0;
     267}
     268//*****************************************************************************************
     269//*****************************************************************************************
     270#endif
Note: See TracChangeset for help on using the changeset viewer.