source: trunk/src/win16ldr/odin.c@ 10367

Last change on this file since 10367 was 5979, checked in by bird, 24 years ago

It now COMPILES with msc60, but can't link it due to missing library files...

File size: 3.5 KB
Line 
1#ifndef MSC6
2#include <windows.h>
3#else
4#include "msc60win.h"
5#endif
6#include <stdlib.h>
7#include <string.h>
8#include <stdio.h>
9#include <string.h>
10#include "peexe.h"
11
12HINSTANCE hinstApp;
13HWND hwnd;
14HINSTANCE hDll;
15
16long FAR PASCAL __export MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
17BOOL InitApplication(HANDLE hInstance);
18BOOL InitInstance(HANDLE hInstance, int nCmdShow);
19HANDLE hModule = 0;
20
21
22//*****************************************************************************************
23//*****************************************************************************************
24int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
25{
26 MSG msg;
27
28 if (!hPrevInstance)
29 if (!InitApplication(hInstance))
30 return (FALSE);
31
32 if (!InitInstance(hInstance, nCmdShow))
33 return (FALSE);
34
35 while(*lpCmdLine == ' ') lpCmdLine++;
36
37 hModule = WinExec(lpCmdLine, SW_SHOW);
38
39 if(hModule >= 32) {
40 while (GetMessage(&msg, NULL, NULL, NULL))
41 {
42 TranslateMessage(&msg);
43 DispatchMessage(&msg);
44 }
45 }
46 else {
47 char errormsg[256];
48
49 sprintf(errormsg, "WinExec %s failed with error %d", lpCmdLine, hModule);
50 MessageBox(hwnd, errormsg, "Ïnternal Error", MB_ICONHAND);
51 DestroyWindow(hwnd);
52 }
53
54 FreeLibrary(hDll);
55 return (msg.wParam);
56}
57//*****************************************************************************************
58//*****************************************************************************************
59BOOL InitApplication(HANDLE hInstance)
60{
61 WNDCLASS wc;
62
63 hDll = LoadLibrary("odindll.dll");
64 if(hDll == 0) {
65 return 0;
66 }
67
68 wc.style = NULL;
69 wc.lpfnWndProc = MainWndProc;
70 wc.cbClsExtra = 0;
71 wc.cbWndExtra = 0;
72 wc.hInstance = hInstance;
73 wc.hIcon = 0;
74 wc.hCursor = 0;
75 wc.hbrBackground = GetStockObject(WHITE_BRUSH);
76 wc.lpszMenuName = NULL;
77 wc.lpszClassName = "Win16OdinClass";
78
79 return (RegisterClass(&wc));
80}
81//*****************************************************************************************
82//*****************************************************************************************
83BOOL InitInstance(HANDLE hInstance, int nCmdShow)
84{
85 hinstApp = hInstance;
86
87 hwnd = CreateWindow(
88 "Win16OdinClass",
89 "Odin Win16 Program Launcher",
90 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
91 CW_USEDEFAULT,
92 CW_USEDEFAULT,
93 CW_USEDEFAULT,
94 CW_USEDEFAULT,
95 NULL,
96 NULL,
97 hInstance,
98 NULL
99 );
100
101 if (!hwnd)
102 return (FALSE);
103
104 return (TRUE);
105
106}
107//*****************************************************************************************
108//*****************************************************************************************
109long FAR PASCAL __export MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
110{
111 char modname[256];
112
113 switch (message) {
114 case WM_CREATE:
115 SetTimer(hWnd, 1234, 500, NULL);
116 return 0;
117
118 case WM_TIMER:
119 if(GetModuleFileName(hModule, modname, sizeof(modname)) == 0) {
120 KillTimer(hWnd, 1234);
121 DestroyWindow(hWnd);
122 }
123 break;
124
125 case WM_DESTROY:
126 PostQuitMessage(0);
127 break;
128
129 default:
130 return (DefWindowProc(hWnd, message, wParam, lParam));
131 }
132 return (NULL);
133}
134//*****************************************************************************************
135//*****************************************************************************************
Note: See TracBrowser for help on using the repository browser.