[wing/wip/user-name] Add wing_get_user_name utility method



commit d520e58a2d67fbddb77afa357f0fdbf94d89ecf7
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Thu Jul 21 15:38:06 2016 +0200

    Add wing_get_user_name utility method

 wing/wingutils.c |   13 +++++++++++++
 wing/wingutils.h |    3 +++
 2 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/wing/wingutils.c b/wing/wingutils.c
index c743386..a583276 100644
--- a/wing/wingutils.c
+++ b/wing/wingutils.c
@@ -72,3 +72,16 @@ wing_get_version_number (gint *major,
 
   return TRUE;
 }
+
+gchar *
+wing_get_user_name (void)
+{
+  wchar_t user_namew[UNLEN + 1];
+  DWORD buf_size = UNLEN + 1;
+  gchar *user_name = NULL;
+
+  if (GetUserNameW(user_name, &buf_size)
+    user_name = g_utf16_to_utf8(user_namew, -1, NULL, NULL, NULL);
+
+  return user_name;
+}
diff --git a/wing/wingutils.h b/wing/wingutils.h
index 390ad20..bc0a44b 100644
--- a/wing/wingutils.h
+++ b/wing/wingutils.h
@@ -33,6 +33,9 @@ WING_AVAILABLE_IN_ALL
 gboolean     wing_get_version_number   (gint *major,
                                         gint *minor);
 
+WING_AVAILABLE_IN_ALL
+gchar       *wing_get_user_name        (void);
+
 G_END_DECLS
 
 #endif /* WING_UTILS_H */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]