Mercurial > vim
diff src/misc1.c @ 14133:352c2832d17f v8.1.0084
patch 8.1.0084: user name completion does not work on MS-Windows
commit https://github.com/vim/vim/commit/828c3d70833a0689cc07581f2a67d06430675da5
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jun 19 18:58:07 2018 +0200
patch 8.1.0084: user name completion does not work on MS-Windows
Problem: User name completion does not work on MS-Windows.
Solution: Use NetUserEnum() to get user names. (Yasuhiro Matsumoto)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 19 Jun 2018 19:00:07 +0200 |
parents | a039c93f5ff7 |
children | 2ad722003b36 |
line wrap: on
line diff
--- 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 }