comparison src/os_win32.c @ 5551:9faba192ea90 v7.4.124

updated for version 7.4.124 Problem: Win32: Getting host name does not use wide function. Solution: Use GetComputerNameW() if possible. (Ken Takata)
author Bram Moolenaar <bram@vim.org>
date Wed, 11 Dec 2013 18:21:45 +0100
parents 32e50f85d2c7
children 45ef9d2096e8
comparison
equal deleted inserted replaced
5550:de073f33c3f2 5551:9faba192ea90
2806 char_u *s, 2806 char_u *s,
2807 int len) 2807 int len)
2808 { 2808 {
2809 DWORD cch = len; 2809 DWORD cch = len;
2810 2810
2811 #ifdef FEAT_MBYTE
2812 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
2813 {
2814 WCHAR wszHostName[256 + 1];
2815 DWORD wcch = sizeof(wszHostName) / sizeof(WCHAR);
2816
2817 if (GetComputerNameW(wszHostName, &wcch))
2818 {
2819 char_u *p = utf16_to_enc(wszHostName, NULL);
2820
2821 if (p != NULL)
2822 {
2823 vim_strncpy(s, p, len - 1);
2824 vim_free(p);
2825 return;
2826 }
2827 }
2828 /* Retry with non-wide function (for Windows 98). */
2829 }
2830 #endif
2811 if (!GetComputerName(s, &cch)) 2831 if (!GetComputerName(s, &cch))
2812 vim_strncpy(s, "PC (Win32 Vim)", len - 1); 2832 vim_strncpy(s, "PC (Win32 Vim)", len - 1);
2813 } 2833 }
2814 2834
2815 2835