| 238 | } |
| 239 | |
| 240 | static THREAD_ENTRY_DECLARE WINDOW_main(THREAD_ENTRY_PARAM) |
| 241 | { |
| 242 | /************************************** |
| 243 | * |
| 244 | * W I N D O W _ m a i n |
| 245 | * |
| 246 | ************************************** |
| 247 | * |
| 248 | * Functional description |
| 249 | * |
| 250 | * This function is where the actual service code starts. |
| 251 | * Do all the window init stuff, then fork off a thread for starting |
| 252 | * the server. |
| 253 | * |
| 254 | **************************************/ |
| 255 | |
| 256 | // If we're a service, don't create a window |
| 257 | if (service_flag) |
| 258 | { |
| 259 | try |
| 260 | { |
| 261 | Thread::start(start_and_watch_server, 0, THREAD_medium, &watcher_thd); |
| 262 | } |
| 263 | catch (const Firebird::Exception&) |
| 264 | { |
| 265 | // error starting server thread |
| 266 | char szMsgString[256]; |
| 267 | LoadString(hInstance_gbl, IDS_CANT_START_THREAD, szMsgString, 256); |
| 268 | gds__log(szMsgString); |
| 269 | } |
| 270 | |
| 271 | return 0; |
| 272 | } |
| 273 | |
| 274 | // Make sure that there is only 1 instance of the guardian running |
| 275 | HWND hWnd = FindWindow(GUARDIAN_CLASS_NAME, GUARDIAN_APP_NAME); |
| 276 | if (hWnd) |
| 277 | { |
| 278 | char szMsgString[256]; |
| 279 | LoadString(hInstance_gbl, IDS_ALREADYSTARTED, szMsgString, 256); |
| 280 | MessageBox(NULL, szMsgString, GUARDIAN_APP_LABEL, MB_OK | MB_ICONSTOP); |
| 281 | gds__log(szMsgString); |
| 282 | return 0; |
| 283 | } |
| 284 | |
| 285 | // initialize main window |
| 286 | WNDCLASS wcl; |
| 287 | wcl.hInstance = hInstance_gbl; |
| 288 | wcl.lpszClassName = GUARDIAN_CLASS_NAME; |
| 289 | wcl.lpfnWndProc = WindowFunc; |
| 290 | wcl.style = 0; |
| 291 | wcl.hIcon = LoadIcon(hInstance_gbl, MAKEINTRESOURCE(IDI_IBGUARD)); |
| 292 | wcl.hCursor = LoadCursor(NULL, IDC_ARROW); |
| 293 | wcl.lpszMenuName = NULL; |
| 294 | wcl.cbClsExtra = 0; |
| 295 | wcl.cbWndExtra = 0; |
| 296 | wcl.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); |
| 297 | |