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.

AdityaKapoorAsked:
Who is Participating?
 
DanRollinsConnect With a Mentor Commented:
From this article, it looks as if there is no particular limit:

    235128 - INFO: Understanding Device Names and Symbolic Links
    http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B235128

since it is possible to create multiple aliases for any NT device.  

How do all of these devices end up in the list?  I'd say that they are put there during system setup and plug-and-play discovery -- each relates to some physical hardware attached to the system, such as disks, scanners, printer ports, sound cards, and so forth.

-- Dan
0
 
DanRollinsCommented:
>>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
0
 
AdityaKapoorAuthor Commented:
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."
0
All Courses

From novice to tech pro — start learning today.