question

AbhishekKumar-8026 avatar image
0 Votes"
AbhishekKumar-8026 asked RLWA32-6355 commented

I am using SetupGetInfFileList function to Scans through all the inf files in the given location and adds information about them to drvList ,but he call is failing and returning ERROR_INSUFFICIENT_BUFFER 122.If the Directorypath is too long.

DWORD BufferSize =0 , RequiredSize =0;

 BOOL bError = SetupGetInfFileList(Directorypath.c_str(), INF_STYLE_WIN4, NULL, BufferSize, &RequiredSize);
    
 if (bError == FALSE)
 { 
           DWORD last_error = GetLastError();
           printf("SetupGetInfFileList 2 Error: %lu\n", last_error);
                     system("PAUSE");
                     return FALSE;

}

windows-apic++
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

RLWA32-6355 avatar image
0 Votes"
RLWA32-6355 answered RLWA32-6355 commented

SetupGetInfFileList appears to follow a pattern that is often used by Windows API functions. The function is called twice. The first call is used to obtain the size of the buffer required to contain the data to be returned. Once the required size is known a buffer is allocated. The second call passes the address and size of the allocated buffer. Even though the function call failed and returned error code 122 did it return a value in the RequiredSize variable? If it did, try allocating a buffer of the required size and call the function again with the address and size of the buffer.

· 8
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for the response.
Ya i have not shared the the second call which is like this

aBuffer = (TCHAR )LocalAlloc(LPTR, dwRequiredSize sizeof (TCHAR));

 if (aBuffer == NULL)
 {
     return RESULT2(ERROR_MEMORY_EXCEPTION);
 }

 BufferSize = RequiredSize;
    
 bError = SetupGetInfFileList(Directorypath.c_str(), INF_STYLE_WIN4 , aBuffer, BufferSize, NULL);

And the answer for second question is it returned 0 for the RequiredSize variable.
I have also read in some Windows OS , we can enable from registry and then there is no limit of 260 characters.But my OS doesn't support that.
Is there any workaround for the same?

0 Votes 0 ·

Are you saying that the first call failed with error code 122 and 0 was returned in the RequiredSize parameter?



0 Votes 0 ·

Yes it returned 0 for the RequiredSize with code 122 .

0 Votes 0 ·
Show more comments