windows-installer-presentation.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. #define WIN32_LEAN_AND_MEAN
  2. #define UNICODE
  3. #include <windows.h>
  4. extern "C" __declspec(dllimport) BOOL __cdecl InstallerPresentWelcome(HWND window);
  5. static bool Above(HWND upper, HWND lower) {
  6. for (HWND current = GetWindow(lower, GW_HWNDPREV); current;
  7. current = GetWindow(current, GW_HWNDPREV)) {
  8. if (current == upper) return true;
  9. }
  10. return false;
  11. }
  12. int wmain() {
  13. HINSTANCE instance = GetModuleHandleW(nullptr);
  14. HWND installer = CreateWindowExW(0, L"STATIC", L"Installer", WS_POPUP,
  15. 100, 100, 300, 300, nullptr, nullptr, instance, nullptr);
  16. HWND other = CreateWindowExW(0, L"STATIC", L"Other", WS_POPUP,
  17. 120, 120, 300, 300, nullptr, nullptr, instance, nullptr);
  18. if (!installer || !other) return 1;
  19. ShowWindow(installer, SW_SHOW);
  20. ShowWindow(other, SW_SHOW);
  21. if (!Above(other, installer)) return 2;
  22. if (!InstallerPresentWelcome(installer)) return 3;
  23. if (!Above(installer, other)) return 4;
  24. if (GetWindowLongPtrW(installer, GWL_EXSTYLE) & WS_EX_TOPMOST) return 5;
  25. if (GetPropW(installer, L"HarnessInstaller.Presented") != reinterpret_cast<HANDLE>(1)) return 6;
  26. DestroyWindow(other);
  27. DestroyWindow(installer);
  28. return 0;
  29. }