Link to home
Start Free TrialLog in
Avatar of AdityaKapoor
AdityaKapoor

asked on

QueryDosDevices

When I put NULL in first Parameter I get names of all the DOS Devices on the system.

If the Buffer is smaller even then this succeeds and does not return a Error.

1) My questions is on What kind of system does The Buffer growes larger, May be say larger then 8192 Bytes.

Avatar of DanRollins
DanRollins
Flag of United States of America image

>>What kind of system does The Buffer growes larger, May be say larger then 8192 Bytes.

Strange question, oddly worded.
I think you are asking if it would be possible for this function to return more than 8192 bytes.  I don't know the answer to that, but my system returns 5552 bytes, so it could easily be possible.

Perhaps you are asking if there is a way to determine if you have gotten all of the information, after all, there is no error message if your buffer is too small.  Here is how I would do it:

Start with a small buffer and, in a loop, keep calling, using a larger and larger buffer until the return value does not change twice in a row:

char* pBuf;
DWORD nLastSize= -1;
for (int j=1000; j< 100000; j+= 1000 ) {
    pBuf=new char[j];
    DWORD nRet= QueryDosDevice( 0, szBuff, j );
    if (nRet == 0 ) break; // and handle the error
    if ( nLastSize == nRet ) {
        break; // all done
    }
    delete[] pBuf;  // get ready for next pass
    nLastSize == nRet;
}

Note: I did not test this code.

-- Dan
Avatar of AdityaKapoor
AdityaKapoor

ASKER

Hi Dan

I also thought twice or thrice how to frame the question but that was the best I could do that point in time

Actually I know that buffer could be more than 8192 bytes as I have seen system where this was 15000 bytes

As far as code was concerned my buffer was 8192 only for this system also. It actually wrote past the buffer successfully.

I came to know only at a latter point so it may happen that even when your size is 1000 in your code it will succeed and you wont get 0 as the return value as in my case.

I have here reworded the question
My question was not regarding the coding aspect it was rather theorytical .

"I wanted to know what actually governs NO of dosdevices on the system."
ASKER CERTIFIED SOLUTION
Avatar of DanRollins
DanRollins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial