Compare commits

...

3 Commits

Author SHA1 Message Date
bol-van
745a8ec928 winws: fix unicode lengths 2024-07-30 20:04:39 +03:00
bol-van
fdb97e4654 winws: minor code fix 2024-07-30 19:52:58 +03:00
bol-van
11f6e07fa7 winws: --nlm-list fix national characters in adapter name 2024-07-30 19:51:18 +03:00
3 changed files with 7 additions and 4 deletions

Binary file not shown.

View File

@ -998,6 +998,8 @@ static bool AdapterID2Name(const GUID *guid,char *name,DWORD name_len)
HKEY hkNetworkCards,hkCard; HKEY hkNetworkCards,hkCard;
DWORD dwIndex,dwLen; DWORD dwIndex,dwLen;
bool bRet = false; bool bRet = false;
WCHAR namew[128];
DWORD namew_len;
if (name_len<2) return false; if (name_len<2) return false;
@ -1024,11 +1026,12 @@ static bool AdapterID2Name(const GUID *guid,char *name,DWORD name_len)
val[dwLen]='\0'; val[dwLen]='\0';
if (!strcmp(val,sguid)) if (!strcmp(val,sguid))
{ {
name_len--; namew_len = sizeof(namew)-sizeof(WCHAR);
if ((w_win32_error = RegQueryValueExA(hkCard,"Description",NULL,NULL,name,&name_len)) == ERROR_SUCCESS) if ((w_win32_error = RegQueryValueExW(hkCard,L"Description",NULL,NULL,(LPBYTE)namew,&namew_len)) == ERROR_SUCCESS)
{ {
name[name_len]='\0'; namew[namew_len/sizeof(WCHAR)]=L'\0';
bRet = true; if (WideCharToMultiByte(CP_UTF8, 0, namew, -1, name, name_len, NULL, NULL))
bRet = true;
} }
} }
} }