Click here to Skip to main content
12,444,790 members (51,535 online)

C / C++ / MFC

 
QuestionHow To Use Macro In dsp file(VC6.0 *.dsp file) Pin
yingkou27-Nov-12 14:59
memberyingkou27-Nov-12 14:59 
SuggestionRe: How To Use Macro In dsp file(VC6.0 *.dsp file) Pin
Albert Holguin27-Nov-12 16:30
memberAlbert Holguin27-Nov-12 16:30 
GeneralRe: How To Use Macro In dsp file(VC6.0 *.dsp file) Pin
yingkou28-Nov-12 21:50
memberyingkou28-Nov-12 21:50 
GeneralRe: How To Use Macro In dsp file(VC6.0 *.dsp file) Pin
Albert Holguin29-Nov-12 4:55
memberAlbert Holguin29-Nov-12 4:55 
QuestionA class for operations with Large Integer Numbers Pin
Pahanuch27-Nov-12 12:39
memberPahanuch27-Nov-12 12:39 
AnswerRe: A class for operations with Large Integer Numbers Pin
Albert Holguin27-Nov-12 16:34
memberAlbert Holguin27-Nov-12 16:34 
AnswerRe: A class for operations with Large Integer Numbers Pin
Stefan_Lang28-Nov-12 3:01
memberStefan_Lang28-Nov-12 3:01 
QuestionSetupDiGetDeviceRegistryProperty - buffer size? Pin
Vaclav_Sal27-Nov-12 6:39
memberVaclav_Sal27-Nov-12 6:39 
SetupDiGetDeviceRegistryProperty API suppose returns required buffer size for "Property" beeing inquired about.
It does but it also returns variety of errors.
( invalid data, data "too short" - whatever that means )

The function never returns true when with parameters are set to return buffer size.
Is that normal?

For example if I inqiure about SPDRP_FRIENDLYNAME   the buffer size returned is 0.

Here is my code, keep in mind it is a test code!
I have aslo included partial MS function desription.

Many thanks for your help.
Cheers Vaclav


     DWORD   DataT;  
     LPTSTR buffer      = NULL;     
     DWORD   buffersize = 0; // 2048; // 0;           
     int iCounter = 0;
     buffer = (LPTSTR)LocalAlloc(LPTR, buffersize * 2);
    
     TRACE("\nSetupDiGetDeviceRegistryProperty...");
     TRACE("\nReturn required buffer size only ");
     Property = SPDRP_FRIENDLYNAME; // SPDRP_DEVTYPE; // SPDRP_COMPATIBLEIDS; // SPDRP_CLASS;
     do
     {
         
     bool bResult = false;
    
     do
     {  
          bResult = SetupDiGetDeviceRegistryProperty(
          hDevInfo,         //      _In_         HDEVINFO DeviceInfoSet,
          &DeviceInfoData,   //   _In_         PSP_DEVINFO_DATA DeviceInfoData
          Property,         //   _In_         DWORD Property,
          &DataT,         //   _Out_opt_   PDWORD PropertyRegDataType,
          NULL,            // get size with NULL (PBYTE)buffer, //      _Out_opt_   PBYTE PropertyBuffer,
          0,                  // get size with 0      buffersize,  
          &buffersize); // fills buffer size
         
            if(buffersize)
          {
               TRACE("\n");
               bResult = SetupDiGetDeviceRegistryProperty(
                    hDevInfo,         //      _In_         HDEVINFO DeviceInfoSet,
                    &DeviceInfoData,   //   _In_         PSP_DEVINFO_DATA DeviceInfoData
                    Property,         //   _In_         DWORD Property,
                    &DataT,         //   _Out_opt_   PDWORD PropertyRegDataType,
                    (PBYTE)buffer, //      _Out_opt_   PBYTE PropertyBuffer,
                    buffersize,  
                    &buffersize); // fills buffer size
                   
          }

          TRACE("\nProperty %i ",Property);
          Property++;
          TRACE("\nProperty %i ",Property);
     }
     while (!bResult & Property <= SPDRP_UPPERFILTERS);





PropertyBuffer [out, optional]
A pointer to a buffer that receives the property that is being retrieved. If this parameter is set to NULL, and PropertyBufferSize is also set to zero, the function returns the required size for the buffer in RequiredSize.
PropertyBufferSize [in]
The size, in bytes, of the PropertyBuffer buffer.
RequiredSize [out, optional]
A pointer to a variable of type DWORD that receives the required size, in bytes, of the PropertyBuffer buffer that is required to hold the data for the requested property. This parameter is optional and can be NULL.
Return value
SetupDiGetDeviceRegistryProperty returns TRUE if the call was successful. Otherwise, it returns FALSE and the logged error can be retrieved by making a call to GetLastError. SetupDiGetDeviceRegistryProperty returns the ERROR_INVALID_DATA error code if the requested property does not exist for a device or if the property data is not valid.
AnswerRe: SetupDiGetDeviceRegistryProperty - buffer size? Pin
Richard MacCutchan27-Nov-12 6:50
mvpRichard MacCutchan27-Nov-12 6:50 
AnswerRe: SetupDiGetDeviceRegistryProperty - buffer size? Pin
Jochen Arndt27-Nov-12 22:54
memberJochen Arndt27-Nov-12 22:54 
GeneralRe: SetupDiGetDeviceRegistryProperty - buffer size? Pin
Vaclav_Sal28-Nov-12 4:50
memberVaclav_Sal28-Nov-12 4:50 
GeneralRe: SetupDiGetDeviceRegistryProperty - buffer size? Pin
Jochen Arndt28-Nov-12 5:35
memberJochen Arndt28-Nov-12 5:35 
GeneralRe: SetupDiGetDeviceRegistryProperty - buffer size? Pin
Vaclav_Sal28-Nov-12 7:03
memberVaclav_Sal28-Nov-12 7:03 
GeneralRe: SetupDiGetDeviceRegistryProperty - buffer size? Pin
Jochen Arndt28-Nov-12 8:19
memberJochen Arndt28-Nov-12 8:19 
GeneralRe: SetupDiGetDeviceRegistryProperty - buffer size? Pin
Vaclav_Sal29-Nov-12 5:52
memberVaclav_Sal29-Nov-12 5:52 
GeneralRe: SetupDiGetDeviceRegistryProperty - buffer size? Pin
Jochen Arndt29-Nov-12 6:49
memberJochen Arndt29-Nov-12 6:49 
GeneralRe: SetupDiGetDeviceRegistryProperty - buffer size? Pin
Vaclav_Sal29-Nov-12 8:23
memberVaclav_Sal29-Nov-12 8:23 
GeneralRe: SetupDiGetDeviceRegistryProperty - buffer size? Pin
Jochen Arndt29-Nov-12 21:16
memberJochen Arndt29-Nov-12 21:16 
GeneralRe: SetupDiGetDeviceRegistryProperty - buffer size? Pin
Vaclav_Sal30-Nov-12 2:43
memberVaclav_Sal30-Nov-12 2:43 
AnswerRe: SetupDiGetDeviceRegistryProperty - buffer size? Pin
Cristian Amarie3-Dec-12 8:58
memberCristian Amarie3-Dec-12 8:58 
GeneralRe: SetupDiGetDeviceRegistryProperty - buffer size? Pin
Vaclav_Sal3-Dec-12 12:39
memberVaclav_Sal3-Dec-12 12:39 
GeneralRe: SetupDiGetDeviceRegistryProperty - buffer size? Pin
Cristian Amarie3-Dec-12 17:37
memberCristian Amarie3-Dec-12 17:37 
GeneralRe: SetupDiGetDeviceRegistryProperty - buffer size? Pin
Cristian Amarie3-Dec-12 18:52
memberCristian Amarie3-Dec-12 18:52 
GeneralRe: SetupDiGetDeviceRegistryProperty - buffer size? Pin
Vaclav_Sal4-Dec-12 5:58
memberVaclav_Sal4-Dec-12 5:58 
GeneralRe: SetupDiGetDeviceRegistryProperty - buffer size? Pin
Cristian Amarie4-Dec-12 7:11
memberCristian Amarie4-Dec-12 7:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web01 | 2.8.160811.3 | Last Updated 23 Aug 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid