Windows API高手进 - C++ Builder / Windows SDK/API
根据 精通Window API 书写下面程序,编译没问题,但运行就出错,提示程序无响应
#include<windows.h>
#include<stdio.h>
#include<stdlib.h>
#define BUFFSIZE 1024
BOOL GetDirverInfo(LPSTR szDrive);
void main(void)
{
CHAR szLogicalDirveStrings[BUFFSIZE];
PCHAR szDrive;
ZeroMemory(szLogicalDirveStrings,BUFFSIZE);
GetLogicalDriveStrings(BUFFSIZE - 1,szLogicalDirveStrings);
szDrive = (PCHAR)szLogicalDirveStrings;
do
{
if(!GetDirverInfo(szDrive))
{
printf("\nGet Volume Information Error: %d",GetLastError());
}
szDrive +=(lstrlen(szDrive)+1);
}
while(*szDrive!='\x00');
}
BOOL GetDirverInfo(LPSTR szDrive)
{
UINT uDriveType;
DWORD dwVolumeSerialNumber;
DWORD dwMaximumComponentLength;
DWORD dwFileSystemFlags;
CHAR szFlieSystemNameBuffer[BUFFSIZE];
CHAR szDirveName[MAX_PATH];
printf("\n%s\n");
uDriveType = GetDriveType(szDrive);
switch(uDriveType)
{
case DRIVE_UNKNOWN:
printf("The drive type cannot be determined.");
break;
case DRIVE_NO_ROOT_DIR:
printf("The root path is invalid,for example,no volume is mounted at the path.");
break;
case DRIVE_REMOVABLE:
printf("The drive is a type that has removable media,for example,a floppy drive or removable hard disk.");
break;
case DRIVE_FIXED:
printf("The drive is a type that cannot be removed,for example,a fixed hard drive.");
break;
case DRIVE_REMOTE:
printf("The driveis a remote (network) drive.");
break;
case DRIVE_CDROM:
printf("The drive is a CD-ROM drive.");
break;
case DRIVE_RAMDISK:
printf("The driveis a RAM disk.");
break;
default:
break;
}
if(!GetVolumeInformation(
szDrive,
szDirveName,
MAX_PATH,
&dwVolumeSerialNumber,
&dwMaximumComponentLength,
&dwFileSystemFlags,
szFlieSystemNameBuffer,
BUFFSIZE))
{
return FALSE;
}
if(0 != lstrlen(szDirveName))
{
printf("\nDrive Name is %s\n",szDirveName);
}
printf("\nVolume Serial Number is %u",dwVolumeSerialNumber);
printf("\nMaximum Component Length is %u",dwMaximumComponentLength);
printf("\nSystem Type is %s\n",szFlieSystemNameBuffer);
if(dwFileSystemFlags & FILE_SUPPORTS_REPARSE_POINTS)
{
printf("The file system does not supports volume mount points.\n");
}
if(dwFileSystemFlags & FILE_VOLUME_QUOTAS)
{
printf("The file system supports disk quotas.\n");
}
if(dwFileSystemFlags & FILE_CASE_SENSITIVE_SEARCH)
{
printf("The file system supports case-sensitive flie.\n");
}
}
找了很多资料不知道为什么
[解决办法]
看到这个了没有,注释掉就ok了,这句是错误的
[color=#FF0000]printf("\n%s\n");[/color]