Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

GetLastError() error code 1784

Status
Not open for further replies.

yawijaya

Member level 2
Joined
Aug 18, 2009
Messages
42
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
New Freedom, PA-USA
Activity points
1,625
I am developing a Windows application to communicate with a USB HID. I've got the firmware working on the device, and windows also recognize it without problem. I am now stumbled on how my software will be able to find the correct device to communicate with. I've read several codes online and pretty much they all refer to the same method of finding the correct device. However, there seems to be a part on the code that is giving me trouble, which is the calling of SetupDiGetDeviceInterfaceDetail function. Here's the piece of the code:

HidD_GetHidGuid(&HidGuid);

hDevInfo=SetupDiGetClassDevs
(&HidGuid,
NULL,
NULL,
DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);


devInfoData.cbSize=sizeof(devInfoData);
LastDevice=FALSE;

Result=SetupDiEnumDeviceInterfaces
(hDevInfo,
0,
&HidGuid,
MemberIndex,
&devInfoData);

if(Result != 0)
{
Result=SetupDiGetDeviceInterfaceDetail
(hDevInfo,
&devInfoData,
NULL,
0,
&Length,
NULL);


detailData=(PSP_DEVICE_INTERFACE_DETAIL_DATA)malloc(Length);


detailData->cbSize=sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
Memo->Text= detailData->cbSize;



Result=SetupDiGetDeviceInterfaceDetail
(hDevInfo,
&devInfoData,
detailData,
Length,
&Required,
NULL);

Result=GetLastError();
Memo->Lines->Add(Result);
}

The GetLastError() would return error code 1784, which is "The supplied user buffer is not valid for the requested operation." Is this error expected? If not, anybody has any suggestion of what I should do?Thanks
 

Hi,

can you try this in the first statement, i think that should do the trick.

hDevInfo =
SetupDiGetClassDevs(&GUID_DEVCLASS_HIDCLASS,
0,
0,
DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
 

After first SetupDiGetDeviceInterfaceDetail, allocate buffer for detailData like below

detailData=(PSP_DEVICE_INTERFACE_DETAIL_DATA)LocalAlloc(LMEM_FIXED, Length);
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top