OSDN Git Service

first
[psychlops/cpp.git] / psychlops / platform / win32 / psychlops_app_main_Win32.h
1 /*\r
2  *  psychlops_app_main_Win32.h\r
3  *  Psychlops Standard Library (Win32)\r
4  *\r
5  *  Last Modified 2006/01/09 by Kenchi HOSOKAWA\r
6  *  (C) 2006 Kenchi HOSOKAWA, Kazushi MARUYA and Takao SATO\r
7  */\r
8 \r
9 \r
10 #ifndef HEADER_PSYCHLOPS_APP_MAIN_WIN32\r
11 #define HEADER_PSYCHLOPS_APP_MAIN_WIN32\r
12 \r
13 \r
14 #include <windows.h>\r
15 #include "../../psychlops_lib.h"
16 #include "../../core/ApplicationInterfaces/psychlops_app_init.h"
17 #include "psychlops_app_state_Win32.h"
18
19 \r
20 \r
21 \r
22         void psychlops_main();\r
23 \r
24 namespace Psychlops {\r
25 \r
26 \r
27 }       /*      <- namespace Psycholops         */\r
28 \r
29 \r
30 extern "C" int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow) {
31
32         MSG msg;
33         msg.wParam = 0;
34         Psychlops::APIApplicationProperties::startupinfo.set(hInstance, hPrevInstance, lpCmdLine, iCmdShow);
35
36         try {\r
37 \r
38                 //      giveio.sys\r
39                 //HANDLE h = CreateFile(CreateFile("\\\\.\\giveio", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);\r
40                 //if(h == INVALID_HANDLE_VALUE) throw "INVALID_HANDLE_VALUE";\r
41                 //CloseHandle(h);\r
42 \r
43                 HANDLE hProcess = GetCurrentProcess();\r
44                 SetPriorityClass(hProcess,NORMAL_PRIORITY_CLASS);\r
45
46                 Psychlops::initialize();\r
47 \r
48                 std::string src(GetCommandLine());\r
49                 std::string::size_type start = 0;\r
50                 while(true){\r
51                         std::string::size_type end = src.find(" ", start);\r
52                         if(end != std::string::npos){\r
53                                 if(end - start!=0)\r
54                                         Psychlops::AppInfo::args.push_back(src.substr(start, end - start));\r
55                         } else {\r
56                                 Psychlops::AppInfo::args.push_back(src.substr(start, src.length() - start));\r
57                                 break;\r
58                         }\r
59                         start = end + 1;\r
60                 }\r
61 \r
62                 psychlops_main();
63                 Psychlops::finalize();
64 \r
65 \r
66         } catch(Psychlops::Exception e) {\r
67 //              if(e.ti_ == typeid(Psychlops::APIInputProperties)) {\r
68 //                      if(Psychlops::Display::the_canvas!=NULL) Psychlops::Display::the_canvas->release();\r
69 //              }
70                 MessageBox( NULL, e.to_s().c_str(), "Psychlops Notification", MB_OK );\r
71                 //Psychlops::APIApplicationProperties::analyzeAPIError();\r
72         } catch(Psychlops::Exception *e) {
73                 MessageBox( NULL, e->to_s().c_str(), "Psychlops Notification", MB_OK );
74         } catch(std::exception e) {\r
75                 MessageBox( NULL, e.what(), "Psychlops Notification : std lib exception", MB_OK );\r
76         } catch(char* str) {\r
77                 MessageBox( NULL, str, "Psychlops Notification", MB_OK );\r
78                 //Psychlops::APIApplicationProperties::analyzeAPIError();\r
79         }\r
80
81 //      return 0;
82         return msg.wParam;
83
84 }\r
85 \r
86 //DWORD WINAPI entryMainThread(LPVOID vdParam);\r
87 \r
88 \r
89 #endif\r