aboutsummaryrefslogtreecommitdiffhomepage
path: root/win32/PlatWin.h
diff options
context:
space:
mode:
Diffstat (limited to 'win32/PlatWin.h')
-rw-r--r--win32/PlatWin.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/win32/PlatWin.h b/win32/PlatWin.h
index 58ba5e78f..0d1c99b48 100644
--- a/win32/PlatWin.h
+++ b/win32/PlatWin.h
@@ -57,6 +57,23 @@ T DLLFunction(HMODULE hModule, LPCSTR lpProcName) noexcept {
return fp;
}
+// Release an IUnknown* and set to nullptr.
+// While IUnknown::Release must be noexcept, it isn't marked as such so produces
+// warnings which are avoided by the catch.
+template <class T>
+void ReleaseUnknown(T *&ppUnknown) noexcept {
+ if (ppUnknown) {
+ try {
+ ppUnknown->Release();
+ }
+ catch (...) {
+ // Never occurs
+ }
+ ppUnknown = nullptr;
+ }
+}
+
+
UINT DpiForWindow(WindowID wid) noexcept;
int SystemMetricsForDpi(int nIndex, UINT dpi) noexcept;