Click here to Skip to main content
15,904,024 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Merging Arrays Pin
Sajeesh Payolam30-Nov-12 18:47
Sajeesh Payolam30-Nov-12 18:47 
QuestionHow to use ribbon in MFC Activex control Pin
Lamourou27-Nov-12 20:23
Lamourou27-Nov-12 20:23 
AnswerRe: How to use ribbon in MFC Activex control Pin
Richard MacCutchan27-Nov-12 23:44
mveRichard MacCutchan27-Nov-12 23:44 
GeneralMessage Closed Pin
28-Nov-12 0:26
Lamourou28-Nov-12 0:26 
GeneralRe: How to use ribbon in MFC Activex control Pin
Richard MacCutchan28-Nov-12 1:10
mveRichard MacCutchan28-Nov-12 1:10 
Questionhow to use more than one rc file in vc6 project at the same time when compiling project Pin
yingkou27-Nov-12 19:59
yingkou27-Nov-12 19:59 
AnswerRe: how to use more than one rc file in vc6 project at the same time when compiling project Pin
Richard MacCutchan27-Nov-12 23:42
mveRichard MacCutchan27-Nov-12 23:42 
GeneralRe: how to use more than one rc file in vc6 project at the same time when compiling project Pin
yingkou28-Nov-12 14:35
yingkou28-Nov-12 14:35 
AnswerRe: how to use more than one rc file in vc6 project at the same time when compiling project Pin
David Crow28-Nov-12 17:33
David Crow28-Nov-12 17:33 
AnswerRe: how to use more than one rc file in vc6 project at the same time when compiling project Pin
Freak3028-Nov-12 23:33
Freak3028-Nov-12 23:33 
Questiontransparency in 32bit bmp in vs2010 Pin
002comp27-Nov-12 19:21
002comp27-Nov-12 19:21 
AnswerRe: transparency in 32bit bmp in vs2010 Pin
Hadi Dayvary27-Nov-12 21:42
professionalHadi Dayvary27-Nov-12 21:42 
GeneralRe: transparency in 32bit bmp in vs2010 Pin
002comp27-Nov-12 23:11
002comp27-Nov-12 23:11 
GeneralRe: transparency in 32bit bmp in vs2010 Pin
Hadi Dayvary28-Nov-12 0:00
professionalHadi Dayvary28-Nov-12 0:00 
QuestionHow To Use Macro In dsp file(VC6.0 *.dsp file) Pin
yingkou27-Nov-12 14:59
yingkou27-Nov-12 14:59 
SuggestionRe: How To Use Macro In dsp file(VC6.0 *.dsp file) Pin
Albert Holguin27-Nov-12 16:30
professionalAlbert Holguin27-Nov-12 16:30 
GeneralRe: How To Use Macro In dsp file(VC6.0 *.dsp file) Pin
yingkou28-Nov-12 21:50
yingkou28-Nov-12 21:50 
GeneralRe: How To Use Macro In dsp file(VC6.0 *.dsp file) Pin
Albert Holguin29-Nov-12 4:55
professionalAlbert Holguin29-Nov-12 4:55 
QuestionA class for operations with Large Integer Numbers Pin
Pahanuch27-Nov-12 12:39
Pahanuch27-Nov-12 12:39 
AnswerRe: A class for operations with Large Integer Numbers Pin
Albert Holguin27-Nov-12 16:34
professionalAlbert Holguin27-Nov-12 16:34 
AnswerRe: A class for operations with Large Integer Numbers Pin
Stefan_Lang28-Nov-12 3:01
Stefan_Lang28-Nov-12 3:01 
QuestionSetupDiGetDeviceRegistryProperty - buffer size? Pin
Vaclav_27-Nov-12 6:39
Vaclav_27-Nov-12 6:39 
AnswerRe: SetupDiGetDeviceRegistryProperty - buffer size? Pin
Richard MacCutchan27-Nov-12 6:50
mveRichard MacCutchan27-Nov-12 6:50 
AnswerRe: SetupDiGetDeviceRegistryProperty - buffer size? Pin
Jochen Arndt27-Nov-12 22:54
professionalJochen Arndt27-Nov-12 22:54 
GeneralRe: SetupDiGetDeviceRegistryProperty - buffer size? Pin
Vaclav_28-Nov-12 4:50
Vaclav_28-Nov-12 4:50 
Here is some of the "calling code", still in test development.( I know it is a mess. sorry)
If I just use this property DWORD Property = SPDRP_DEVICEDESC;
I still get error when looking for the buffewr size only,
but get the size OK.

Than I get another error - something "the parameter passed to the system is too small". I am trying to find some explanation for this error just for the SetupDiGetDeviceRegistryProperty.There are tons of posts about this error , but nothing specific for this function I found so far.

What bugs me is that ewerybody is copying the original MS device iteration sample code and set the buffer to value and when it fails ( allegedly for Win2000 only ) they increase it. That tells me that the setting for finding the buffer size may not really work, hence all these errors.

Thanks for all you help, appreciate it.




bool C_USB::C_Enumerate_All()
{
TRACE("\nbool C_USB::C_Enumerate_All()");
HDEVINFO hDevInfo;
SP_DEVINFO_DATA DeviceInfoData;
CString strLabel = "Friendly name ";
DWORD i;
TRACE("\nCreate a HDEVINFO with all present devices");
TRACE("\nSetupDiGetClassDevs... Create a HDEVINFO with all present devices");
hDevInfo = SetupDiGetClassDevs(
NULL,
0, // Enumerator
0,
DIGCF_PRESENT | DIGCF_ALLCLASSES);

if (INVALID_HANDLE_VALUE == hDevInfo)
{
TRACE("\nINVALID_HANDLE_VALUE == hDevInfo");
// Insert error handling here.
return 1;
}

// Enumerate through all devices in Set.
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
TRACE("\nSetupDiEnumDeviceInfo...Enumerate through all devices in Set");
/*
DeviceInfoSet [in]
A handle to the device information set for which to return an SP_DEVINFO_DATA
structure that represents a device information element.
MemberIndex [in]
A zero-based index of the device information element to retrieve.
DeviceInfoData [out]
A pointer to an SP_DEVINFO_DATA structure to receive information about
an enumerated device information element. The caller must
set DeviceInfoData.cbSize to sizeof(SP_DEVINFO_DATA).

*/
for (i = 0; SetupDiEnumDeviceInfo(hDevInfo, i, &DeviceInfoData); i++)
{
//LPTSTR buffer = NULL;
//DWORD buffersize = 0;
//TRACE("\nShow property using friendly name flag");
TRACE("\nTest show device description ");
DWORD Property = SPDRP_DEVICEDESC;

C_TestPrintProperty(
hDevInfo,
DeviceInfoData,
strLabel,
Property);
/* enumerate all properties test
do
{
C_TestPrintProperty(
hDevInfo,
DeviceInfoData,
strLabel,
Property);

// Property++;
TRACE("\nEnumerate property counter %i", Property);
}while (Property++ != SPDRP_MAXIMUM_PROPERTY);
*/

TRACE("\nEnumerate progress counter %i", i);
}



void C_USB::C_TestPrintProperty(
HDEVINFO hDevInfo,
SP_DEVINFO_DATA DeviceInfoData,
CString strLabel,
DWORD Property)
{
TRACE("\n void C_USB::C_TestPrintProperty(CString strLabel)");
DWORD DataT;
LPTSTR buffer = NULL;
DWORD buffersize = 2048; // 0;
int iCounter = 0;
bool bResult = false;


//buffer = (LPTSTR)LocalAlloc(LPTR, buffersize * 2);

TRACE("\nSetupDiGetDeviceRegistryProperty...");
TRACE("\nReturn required buffer size only ");
// Property = 0; //SPDRP_FRIENDLYNAME; // SPDRP_DEVTYPE; // SPDRP_COMPATIBLEIDS; // SPDRP_CLASS;

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

// check result
if(!bResult)
{
TRACE("\nMFC Error dialog ");
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
0, // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
// Process any inserts in lpMsgBuf.
// ...
// Display the string.
MessageBox( (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
// Free the buffer.
LocalFree( lpMsgBuf );
goto TEMP;

}
if(buffersize)
{
TRACE("\nFill buffer with property data ");
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
// check result
if(!bResult)
{
TRACE("\nMFC Error dialog ");
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
0, // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
// Process any inserts in lpMsgBuf.
// ...
// Display the string.
MessageBox( (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
// Free the buffer.
LocalFree( lpMsgBuf );

}

}
TEMP:
TRACE("\nBuffer %s ",buffer);
TRACE("\nProperty %i ",Property);
return;

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.