Skip to content

Commit fd05b82

Browse files
committed
Fixed 15 character device name limit
1 parent 696ddcc commit fd05b82

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

OCSInventory Front/Deviceid.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,16 @@ BOOL CDeviceid::CompareMacs( CString &csRefList, CString &csActualList)
240240
****/
241241
void CDeviceid::checkDeviceid()
242242
{
243+
//Per https://docs.microsoft.com/en-us/windows/win32/sysinfo/computer-names
244+
#define MAX_DNS_COMPONENT_LENGTH 63
245+
243246
CString csDeviceID, csFileDeviceID, csActualMac, csFileMac, csFileHostname;
244-
TCHAR lpHostname[MAX_COMPUTERNAME_LENGTH + 1];
247+
TCHAR lpHostname[MAX_DNS_COMPONENT_LENGTH + 1];
245248
CLog *pLogger = getOcsLogger();
246249
BOOL bMacChanged = FALSE;
247250

248251
DWORD size = sizeof( lpHostname );
249-
GetComputerName( lpHostname, &size);
252+
GetComputerNameEx((COMPUTER_NAME_FORMAT)ComputerNameDnsHostname, lpHostname, &size);
250253
m_csHostName = lpHostname;
251254

252255
// Load deviceid from .dat file

0 commit comments

Comments
 (0)