GetLogicalDrives 获取磁盘问题

C/C++ code
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//函数功能:获取驱动器
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void CTreeViewDlg::GetLogicalDrives(HTREEITEM hParent)
{
    size_t szAllDriveStrings = GetLogicalDriveStrings(0,NULL);   [color=#FF0000]这szAllDriveStrings 编译之后为什么是29呢????搞不懂 这个函数参数这样填还有意义吗?[/color]
    char *pDriveStrings = new char[szAllDriveStrings + sizeof(_T(""))];
    GetLogicalDriveStrings(szAllDriveStrings,pDriveStrings);//感觉这边这样还差不多
    size_t szDriveString = strlen(pDriveStrings);
    while(szDriveString > 0)
    {
        m_tree.InsertItem(pDriveStrings,hParent);
        pDriveStrings += szDriveString + 1;
        szDriveString = strlen(pDriveStrings);
    }
}

作者: z8323664   发布时间: 2011-06-15

If the function succeeds, the return value is the length, in characters, of the strings copied to the buffer, not including the terminating null character. Note that an ANSI-ASCII null character uses one byte, but a Unicode null character uses two bytes.

If the buffer is not large enough, the return value is greater than nBufferLength. It is the size of the buffer required to hold the drive strings.

If the function fails, the return value is zero. To get extended error information, use the GetLastError function.

作者: VisualEleven   发布时间: 2011-06-15

看不懂英语 谁解释下~~

作者: z8323664   发布时间: 2011-06-15

问题是 0,NULL

作者: z8323664   发布时间: 2011-06-15

我顶!!!!!!!!

作者: z8323664   发布时间: 2011-06-15

If the function succeeds, the return value is the length, in characters, of the strings copied to the buffer, not including the terminating null character. Note that an ANSI-ASCII null character uses one byte, but a Unicode null character uses two bytes.(如果函数调用成功,返回值是拷贝到缓冲区的字符串长度,其中不包括'\0'字符,注意到ANSI-ASCII是用一个字节保存一个字符的,而Unicode是用两个字节来保存一个字符的)

If the buffer is not large enough, the return value is greater than nBufferLength. It is the size of the buffer required to hold the drive strings.(如果缓冲区不够大的话,返回值会大于nBufferLength,这个告诉我们缓冲区要多大才可以保存下磁盘的盘符)

If the function fails, the return value is zero. To get extended error information, use the GetLastError function.(如果函数失败,返回值为0,要获得错误信息,请用GetLastError函数)

作者: maoxing63570   发布时间: 2011-06-15