Changeset 21308 for trunk/src/win16ldr/odin.c
- Timestamp:
- Jun 18, 2009, 6:27:45 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/src/win16ldr/odin.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/win16ldr/odin.c
r5979 r21308 1 #if ndef MSC61 #ifdef WATCOMC 2 2 #include <windows.h> 3 3 #else 4 4 #include "msc60win.h" 5 5 #endif 6 //#include <ddeml.h> 6 7 #include <stdlib.h> 7 8 #include <string.h> … … 19 20 HANDLE hModule = 0; 20 21 22 typedef void (FAR * PASCAL FUNC_SetPELdr)(LPCSTR); 23 24 #ifdef DDE_COMM 25 HDDEDATA CALLBACK MyDdeCallback(UINT wType, UINT wFmt, HCONV hConv, HSZ hsz1, HSZ hsz2, HDDEDATA hData, DWORD dwData1, DWORD dwData2); 26 27 DWORD idInst = 0; 28 HSZ hszServer = 0, hszTopic = 0; 29 30 #define MSG_DDE_WILDCONNECT WM_USER+1 31 #define MSG_DDE_CONNECT WM_USER+2 32 #endif 21 33 22 34 //***************************************************************************************** … … 25 37 { 26 38 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 } 27 75 28 76 if (!hPrevInstance) … … 32 80 if (!InitInstance(hInstance, nCmdShow)) 33 81 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 34 99 35 100 while(*lpCmdLine == ' ') lpCmdLine++; … … 48 113 49 114 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); 51 116 DestroyWindow(hwnd); 52 117 } 53 118 119 #ifdef DDE_COMM 120 DdeNameService(idInst, hszServer, 0, DNS_UNREGISTER); 121 DdeFreeStringHandle(idInst, hszServer); 122 DdeFreeStringHandle(idInst, hszTopic); 123 DdeUninitialize(idInst); 124 #endif 54 125 FreeLibrary(hDll); 55 126 return (msg.wParam); … … 60 131 { 61 132 WNDCLASS wc; 62 63 hDll = LoadLibrary("odindll.dll");64 if(hDll == 0) {65 return 0;66 }67 133 68 134 wc.style = NULL; … … 88 154 "Win16OdinClass", 89 155 "Odin Win16 Program Launcher", 156 #if 1 157 WS_POPUP, 158 #else 90 159 WS_OVERLAPPEDWINDOW | WS_VISIBLE, 160 #endif 91 161 CW_USEDEFAULT, 92 162 CW_USEDEFAULT, … … 127 197 break; 128 198 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 129 206 default: 130 207 return (DefWindowProc(hWnd, message, wParam, lParam)); … … 132 209 return (NULL); 133 210 } 134 //***************************************************************************************** 135 //***************************************************************************************** 211 #ifdef DDE_COMM 212 //***************************************************************************************** 213 //***************************************************************************************** 214 HDDEDATA 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.
