summaryrefslogtreecommitdiffstats
path: root/src/misc1.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-06-19 18:58:07 +0200
committerBram Moolenaar <Bram@vim.org>2018-06-19 18:58:07 +0200
commit828c3d70833a0689cc07581f2a67d06430675da5 (patch)
tree612b23768f415285a94cce0044b594866a2ea5bb /src/misc1.c
parent8516071124dbb7ad7caa43cc98ae3c57ae093c9e (diff)
patch 8.1.0084: user name completion does not work on MS-Windowsv8.1.0084
Problem: User name completion does not work on MS-Windows. Solution: Use NetUserEnum() to get user names. (Yasuhiro Matsumoto)
Diffstat (limited to 'src/misc1.c')
-rw-r--r--src/misc1.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/misc1.c b/src/misc1.c
index 76f50258ad..d797a0bc65 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -14,6 +14,10 @@
#include "vim.h"
#include "version.h"
+#if defined(FEAT_CMDL_COMPL) && defined(WIN3264)
+# include <lm.h>
+#endif
+
static char_u *vim_version_dir(char_u *vimdir);
static char_u *remove_tail(char_u *p, char_u *pend, char_u *name);
#if defined(FEAT_CMDL_COMPL)
@@ -4603,6 +4607,28 @@ init_users(void)
}
endpwent();
}
+# elif defined(WIN3264)
+ {
+ char_u* user;
+ DWORD nusers = 0, ntotal = 0, i;
+ PUSER_INFO_0 uinfo;
+
+ if (NetUserEnum(NULL, 0, 0, (LPBYTE *) &uinfo, MAX_PREFERRED_LENGTH,
+ &nusers, &ntotal, NULL) == NERR_Success)
+ {
+ for (i = 0; i < nusers; i++)
+ {
+ if (ga_grow(&ga_users, 1) == FAIL)
+ break;
+ user = utf16_to_enc(uinfo[i].usri0_name, NULL);
+ if (user == NULL)
+ break;
+ ((char_u **)(ga_users.ga_data))[ga_users.ga_len++] = user;
+ }
+
+ NetApiBufferFree(uinfo);
+ }
+ }
# endif
}