No Description

TestApp1.cpp 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // TestApp1.cpp : Defines the entry point for the application.
  2. //
  3. #ifdef _WIN32
  4. #include "Win32/stdafx.h"
  5. #endif
  6. #include <DK.h>
  7. class TestApp1 : public DKApplication
  8. {
  9. DKObject<DKThread> thread;
  10. public:
  11. void OnInitialize(void) override
  12. {
  13. DKLog("---- SystemPath ----");
  14. DKLog("SystemRoot: %ls", (const wchar_t*)DefaultPath(SystemPath::SystemRoot));
  15. DKLog("AppRoot: %ls", (const wchar_t*)DefaultPath(SystemPath::AppRoot));
  16. DKLog("AppResource: %ls", (const wchar_t*)DefaultPath(SystemPath::AppResource));
  17. DKLog("AppExecutable: %ls", (const wchar_t*)DefaultPath(SystemPath::AppExecutable));
  18. DKLog("AppData: %ls", (const wchar_t*)DefaultPath(SystemPath::AppData));
  19. DKLog("UserHome: %ls", (const wchar_t*)DefaultPath(SystemPath::UserHome));
  20. DKLog("UserDocuments: %ls", (const wchar_t*)DefaultPath(SystemPath::UserDocuments));
  21. DKLog("UserPreferences: %ls", (const wchar_t*)DefaultPath(SystemPath::UserPreferences));
  22. DKLog("UserCache: %ls", (const wchar_t*)DefaultPath(SystemPath::UserCache));
  23. DKLog("UserTemp: %ls", (const wchar_t*)DefaultPath(SystemPath::UserTemp));
  24. DKLog("---- ProcessInfo ----");
  25. DKLog("HostName: %ls", (const wchar_t*)ProcessInfoString(ProcessInfo::HostName));
  26. DKLog("OsName: %ls", (const wchar_t*)ProcessInfoString(ProcessInfo::OsName));
  27. DKLog("UserName: %ls", (const wchar_t*)ProcessInfoString(ProcessInfo::UserName));
  28. DKLog("ModulePath: %ls", (const wchar_t*)ProcessInfoString(ProcessInfo::ModulePath));
  29. thread = DKThread::Create(DKFunction([this]()
  30. {
  31. this->EventLoop()->Post(DKFunction([&]()
  32. {
  33. DKLog("test1");
  34. })->Invocation(), 2);
  35. this->EventLoop()->Post(DKFunction([&]()
  36. {
  37. DKLog("test2");
  38. })->Invocation(), 4);
  39. this->EventLoop()->Post(DKFunction([&]()
  40. {
  41. DKLog("Terminate!!");
  42. DKApplication::Instance()->Terminate(0);
  43. })->Invocation(), 6);
  44. })->Invocation());
  45. }
  46. void OnTerminate(void) override
  47. {
  48. thread->WaitTerminate();
  49. }
  50. };
  51. #ifdef _WIN32
  52. int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
  53. _In_opt_ HINSTANCE hPrevInstance,
  54. _In_ LPWSTR lpCmdLine,
  55. _In_ int nCmdShow)
  56. #else
  57. int main(int argc, const char * argv[])
  58. #endif
  59. {
  60. TestApp1 app;
  61. return app.Run();
  62. }