]>
Commit | Line | Data |
---|---|---|
77a37381 | 1 | // tester1.cpp : Defines the entry point for the application. |
2 | // | |
3 | ||
4 | #include "stdafx.h" | |
5 | #include "tester1.h" | |
6 | #include <commctrl.h> | |
7 | //#include <aygshell.h> | |
8 | #include <sipapi.h> | |
9 | #include "setup.h" | |
10 | ||
11 | #define MAX_LOADSTRING 100 | |
12 | ||
13 | // Global Variables: | |
14 | HINSTANCE hInst; // The current instance | |
15 | HWND hwndCB; // The command bar handle | |
16 | ||
17 | //static SHACTIVATEINFO s_sai; | |
18 | ||
19 | ATOM MyRegisterClass (HINSTANCE, LPTSTR); | |
20 | BOOL InitInstance (HINSTANCE, int); | |
21 | LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM); | |
22 | LRESULT CALLBACK About (HWND, UINT, WPARAM, LPARAM); | |
23 | HWND CreateRpCommandBar(HWND); | |
24 | ||
c5f1f439 | 25 | |
77a37381 | 26 | #pragma warning(disable: 4100 4710 4189; error: 4701) |
27 | /* who cares?! | |
28 | 4100: whining about parameters not being used. | |
29 | 4710: whining about screwing up inlining. | |
30 | 4189: initialized but not used. make that an error: later. | |
31 | 4701: usage w/o initialization. | |
32 | */ | |
c5f1f439 | 33 | |
77a37381 | 34 | int WINAPI WinMain( HINSTANCE hInstance, |
35 | HINSTANCE hPrevInstance, | |
36 | LPTSTR lpCmdLine, | |
37 | int nCmdShow) | |
38 | { | |
39 | MSG msg; | |
40 | HACCEL hAccelTable; | |
41 | ||
42 | // Perform application initialization: | |
43 | if (!InitInstance (hInstance, nCmdShow)) | |
44 | { | |
45 | return FALSE; | |
46 | } | |
47 | ||
48 | hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_TESTER1); | |
49 | ||
50 | // Main message loop: | |
51 | while (GetMessage(&msg, NULL, 0, 0)) | |
52 | { | |
53 | if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) | |
54 | { | |
55 | TranslateMessage(&msg); | |
56 | DispatchMessage(&msg); | |
57 | } | |
58 | } | |
59 | ||
60 | return msg.wParam; | |
61 | } | |
62 | ||
63 | // | |
64 | // FUNCTION: MyRegisterClass() | |
65 | // | |
66 | // PURPOSE: Registers the window class. | |
67 | // | |
68 | // COMMENTS: | |
69 | // | |
70 | // It is important to call this function so that the application | |
71 | // will get 'well formed' small icons associated with it. | |
72 | // | |
73 | ATOM MyRegisterClass(HINSTANCE hInstance, LPTSTR szWindowClass) | |
74 | { | |
75 | WNDCLASS wc; | |
76 | ||
77 | wc.style = CS_HREDRAW | CS_VREDRAW; | |
78 | wc.lpfnWndProc = (WNDPROC) WndProc; | |
79 | wc.cbClsExtra = 0; | |
80 | wc.cbWndExtra = 0; | |
81 | wc.hInstance = hInstance; | |
82 | wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TESTER1)); | |
83 | wc.hCursor = 0; | |
84 | wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); | |
85 | wc.lpszMenuName = 0; | |
86 | wc.lpszClassName = szWindowClass; | |
87 | ||
88 | return RegisterClass(&wc); | |
89 | } | |
c5f1f439 | 90 | |
91 | HANDLE OpenCOM1() { | |
92 | ||
93 | static HANDLE COM1handle = INVALID_HANDLE_VALUE; | |
94 | const char msg[] = "\r\n--------linexec--------\r\n"; | |
95 | unsigned long wrote; | |
96 | int speed = CBR_115200; | |
97 | HANDLE h; | |
98 | ||
99 | if (COM1handle != INVALID_HANDLE_VALUE) | |
100 | return (COM1handle); | |
101 | ||
102 | h = CreateFile(TEXT("COM1:"), | |
103 | GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, | |
104 | NULL); | |
105 | if (h == INVALID_HANDLE_VALUE) | |
106 | return (h); | |
107 | ||
108 | DCB dcb; | |
109 | if (!GetCommState(h, &dcb)) | |
110 | goto bad; | |
111 | ||
112 | dcb.BaudRate = speed; | |
113 | if (!SetCommState(h, &dcb)) | |
114 | goto bad; | |
115 | ||
116 | // Print banner on serial console. | |
117 | WriteFile(h, msg, sizeof msg, &wrote, 0); | |
118 | ||
119 | COM1handle = h; | |
120 | ||
121 | return (h); | |
122 | bad: | |
123 | CloseHandle(h); | |
124 | return (INVALID_HANDLE_VALUE); | |
125 | } | |
77a37381 | 126 | |
127 | // | |
128 | // FUNCTION: InitInstance(HANDLE, int) | |
129 | // | |
130 | // PURPOSE: Saves instance handle and creates main window | |
131 | // | |
132 | // COMMENTS: | |
133 | // | |
134 | // In this function, we save the instance handle in a global variable and | |
135 | // create and display the main program window. | |
136 | // | |
137 | ||
138 | BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) | |
139 | { | |
c5f1f439 | 140 | HWND hWnd = NULL; |
141 | TCHAR szTitle[MAX_LOADSTRING]; // The title bar text | |
77a37381 | 142 | TCHAR szWindowClass[MAX_LOADSTRING]; // The window class name |
c5f1f439 | 143 | |
144 | hInst = hInstance; // Store instance handle in our global variable | |
145 | // Initialize global string | |
146 | LoadString(hInstance, IDC_TESTER1, szWindowClass, MAX_LOADSTRING); | |
77a37381 | 147 | LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); |
c5f1f439 | 148 | |
77a37381 | 149 | //If it is already running, then focus on the window |
150 | hWnd = FindWindow(szWindowClass, szTitle); | |
151 | if (hWnd) | |
152 | { | |
153 | SetForegroundWindow ((HWND) (((DWORD)hWnd) | 0x01)); | |
154 | return 0; | |
155 | } | |
156 | ||
157 | MyRegisterClass(hInstance, szWindowClass); | |
158 | ||
159 | RECT rect; | |
160 | GetClientRect(hWnd, &rect); | |
c5f1f439 | 161 | |
77a37381 | 162 | OpenCOM1(); |
163 | load_boot("\\My Documents\\params.txt"); | |
164 | load_boot("\\Storage Card\\params.txt"); | |
b3b3aa8d | 165 | load_boot("\\Speicherkarte\\params.txt"); |
166 | load_boot("\\Carte de stockage\\params.txt"); | |
167 | load_boot("\\Mes documents\\params.txt"); | |
2f5d6735 | 168 | load_boot("\\My Handheld PC\\Storage Card\\params.txt"); |
c5f1f439 | 169 |