diff common/util.c @ 321:824ef90a6721

Move is_elevated into common/util.c file for better reuse
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 07 Apr 2014 10:58:47 +0000
parents
children 31ba7ed4d50f
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/util.c	Mon Apr 07 10:58:47 2014 +0000
@@ -0,0 +1,26 @@
+#include "util.h"
+#ifdef WIN32
+#include <windows.h>
+#endif
+
+#ifdef WIN32
+bool
+is_elevated() {
+    HANDLE hToken = NULL;
+    bool ret = false;
+    if (OpenProcessToken (GetCurrentProcess(), TOKEN_QUERY, &hToken))
+      {
+        DWORD elevation;
+        DWORD cbSize = sizeof (DWORD);
+        if (GetTokenInformation (hToken, TokenElevation, &elevation,
+                                 sizeof (TokenElevation), &cbSize))
+          {
+            ret = elevation;
+          }
+      }
+    if (hToken)
+      CloseHandle (hToken);
+
+    return ret;
+}
+#endif

http://wald.intevation.org/projects/trustbridge/