Help with SetupDiGetDeviceRegistryProperty

Hi,
i am using SetupDiGetDeviceRegistryProperty in my application, but on using this i always get an access violation later on in my application.
i have used the function call like this (Delphi)
while not SetupDiGetDeviceRegistryPropertyA

(hDevInfo,DeviceInfoData,SPDRP_DEVICEDESC,DataT,PByte

(buffer),buffersize,PDWORD(buffersize)) do

begin
if (GetLastError() = ERROR_INSUFFICIENT_BUFFER) then
begin
ReallocMem(buffer,bufferSize);
end
end;

And then in the end i free the memory allocated to buffer.Have i forgotten to do something ?


Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!

Hi Anjita,

Assuming that, u had got hDevInfo and DeviceInfoData correctly,

just try this and it works well for me…

while (!SetupDiGetDeviceRegistryProperty(
hDevInfo,
&DeviceInfoData,
SPDRP_CLASSGUID,
&DataT,
(PBYTE)buffer,
buffersize,
&buffersize))
{
if (GetLastError() ==
ERROR_INSUFFICIENT_BUFFER)
{
// Change the buffer size.
if (buffer) LocalFree(buffer);
buffer = (char *)LocalAlloc(LPTR,buffersize);
}
else
{
// Insert error handling here.
break;
}
}

regards,

shiv

----- Original Message -----
From: anjita jachak
To: NT Developers Interest List
Sent: Monday, September 30, 2002 11:30 AM
Subject: [ntdev] Help with SetupDiGetDeviceRegistryProperty

Hi,

i am using SetupDiGetDeviceRegistryProperty in my application, but on using this i always get an access violation later on in my application.

i have used the function call like this (Delphi)

while not SetupDiGetDeviceRegistryPropertyA

(hDevInfo,DeviceInfoData,SPDRP_DEVICEDESC,DataT,PByte

(buffer),buffersize,PDWORD(buffersize)) do

begin
if (GetLastError() = ERROR_INSUFFICIENT_BUFFER) then
begin
ReallocMem(buffer,bufferSize);
end
end;

And then in the end i free the memory allocated to buffer.Have i forgotten to do something ?


Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo! — You are currently subscribed to ntdev as: xxxxx@rassit.com To unsubscribe send a blank email to %%email.unsub%%