@@ -317,7 +317,8 @@ GetDeviceManufacturerString(IN HDEVINFO DeviceInfoSet,
317
317
318
318
319
319
BOOL
320
- GetDeviceLocationString (IN DEVINST dnDevInst OPTIONAL ,
320
+ GetDeviceLocationString (IN HDEVINFO DeviceInfoSet ,
321
+ IN PSP_DEVINFO_DATA DeviceInfoData ,
321
322
IN DEVINST dnParentDevInst OPTIONAL ,
322
323
OUT LPWSTR szBuffer ,
323
324
IN DWORD BufferSize )
@@ -326,68 +327,104 @@ GetDeviceLocationString(IN DEVINST dnDevInst OPTIONAL,
326
327
ULONG DataSize ;
327
328
CONFIGRET cRet ;
328
329
LPWSTR szFormatted ;
330
+ HKEY hKey ;
331
+ DWORD dwSize , dwType ;
329
332
BOOL Ret = FALSE;
330
333
331
334
DataSize = BufferSize * sizeof (WCHAR );
332
335
szBuffer [0 ] = L'\0' ;
333
- if (dnParentDevInst != 0 )
336
+
337
+ hKey = SetupDiOpenDevRegKey (DeviceInfoSet ,
338
+ DeviceInfoData ,
339
+ DICS_FLAG_GLOBAL ,
340
+ 0 ,
341
+ DIREG_DRV ,
342
+ KEY_QUERY_VALUE );
343
+ if (hKey != INVALID_HANDLE_VALUE )
334
344
{
335
- /* query the parent node name */
336
- if (CM_Get_DevNode_Registry_Property (dnParentDevInst ,
337
- CM_DRP_DEVICEDESC ,
338
- & RegDataType ,
339
- szBuffer ,
340
- & DataSize ,
341
- 0 ) == CR_SUCCESS &&
342
- RegDataType == REG_SZ &&
343
- LoadAndFormatString (hDllInstance ,
344
- IDS_DEVONPARENT ,
345
- & szFormatted ,
346
- szBuffer ) != 0 )
345
+ /* query the LocationInformationOverride value */
346
+ dwSize = BufferSize ;
347
+ if (RegQueryValueEx (hKey ,
348
+ L"LocationInformationOverride" ,
349
+ NULL ,
350
+ & dwType ,
351
+ (LPBYTE )szBuffer ,
352
+ & dwSize ) == ERROR_SUCCESS &&
353
+ dwType == REG_SZ &&
354
+ szBuffer [0 ] != L'\0' )
347
355
{
348
- wcsncpy (szBuffer ,
349
- szFormatted ,
350
- BufferSize - 1 );
351
- szBuffer [BufferSize - 1 ] = L'\0' ;
352
- LocalFree ((HLOCAL )szFormatted );
353
356
Ret = TRUE;
354
357
}
355
- }
356
- else if (dnDevInst != 0 )
357
- {
358
- cRet = CM_Get_DevNode_Registry_Property (dnDevInst ,
359
- CM_DRP_LOCATION_INFORMATION ,
360
- & RegDataType ,
361
- szBuffer ,
362
- & DataSize ,
363
- 0 );
364
- if (cRet == CR_SUCCESS && RegDataType == REG_SZ )
358
+ else
365
359
{
366
- /* FIXME - check string for NULL termination! */
367
- Ret = TRUE;
360
+ szBuffer [0 ] = L'\0' ;
368
361
}
369
362
370
- if (Ret && szBuffer [0 ] >= L'0' && szBuffer [0 ] <= L'9' )
363
+ RegCloseKey (hKey );
364
+ }
365
+
366
+
367
+ if (!Ret )
368
+ {
369
+ if (dnParentDevInst != 0 )
371
370
{
372
- /* convert the string to an integer value and create a
373
- formatted string */
374
- ULONG ulLocation = (ULONG )wcstoul (szBuffer ,
375
- NULL ,
376
- 10 );
377
- if (LoadAndFormatString (hDllInstance ,
378
- IDS_LOCATIONSTR ,
379
- & szFormatted ,
380
- ulLocation ,
381
- szBuffer ) != 0 )
371
+ /* query the parent node name */
372
+ if (CM_Get_DevNode_Registry_Property (dnParentDevInst ,
373
+ CM_DRP_DEVICEDESC ,
374
+ & RegDataType ,
375
+ szBuffer ,
376
+ & DataSize ,
377
+ 0 ) == CR_SUCCESS &&
378
+ RegDataType == REG_SZ &&
379
+ LoadAndFormatString (hDllInstance ,
380
+ IDS_DEVONPARENT ,
381
+ & szFormatted ,
382
+ szBuffer ) != 0 )
382
383
{
383
384
wcsncpy (szBuffer ,
384
385
szFormatted ,
385
386
BufferSize - 1 );
386
387
szBuffer [BufferSize - 1 ] = L'\0' ;
387
388
LocalFree ((HLOCAL )szFormatted );
389
+ Ret = TRUE;
390
+ }
391
+ }
392
+ else if (DeviceInfoData -> DevInst != 0 )
393
+ {
394
+ cRet = CM_Get_DevNode_Registry_Property (DeviceInfoData -> DevInst ,
395
+ CM_DRP_LOCATION_INFORMATION ,
396
+ & RegDataType ,
397
+ szBuffer ,
398
+ & DataSize ,
399
+ 0 );
400
+ if (cRet == CR_SUCCESS && RegDataType == REG_SZ )
401
+ {
402
+ /* FIXME - check string for NULL termination! */
403
+ Ret = TRUE;
404
+ }
405
+
406
+ if (Ret && szBuffer [0 ] >= L'0' && szBuffer [0 ] <= L'9' )
407
+ {
408
+ /* convert the string to an integer value and create a
409
+ formatted string */
410
+ ULONG ulLocation = (ULONG )wcstoul (szBuffer ,
411
+ NULL ,
412
+ 10 );
413
+ if (LoadAndFormatString (hDllInstance ,
414
+ IDS_LOCATIONSTR ,
415
+ & szFormatted ,
416
+ ulLocation ,
417
+ szBuffer ) != 0 )
418
+ {
419
+ wcsncpy (szBuffer ,
420
+ szFormatted ,
421
+ BufferSize - 1 );
422
+ szBuffer [BufferSize - 1 ] = L'\0' ;
423
+ LocalFree ((HLOCAL )szFormatted );
424
+ }
425
+ else
426
+ Ret = FALSE;
388
427
}
389
- else
390
- Ret = FALSE;
391
428
}
392
429
}
393
430
0 commit comments