C语言系统编程资料

相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
printf ("The file system supports disk quotas.\n"); } if(dwFileSystemFlags & FILE_CASE_SENSITIVE_SEARCH) {
printf ("The file system supports case-sensitive file names.\n"); }
DWORD dwSectPerClust, dwBytesPerSect, dwFreeClusters, dwTotalClusters; DWORD i = 0; BOOL bResult;
bResult = GetDiskFreeSpace (pszDrive, &dwSectPerClust, &dwBytesPerSect,&dwFreeClusters, &dwTotalClusters);
break;
default:
printf("Nothing!\n");
break;
}
GetVolumeInformation(szDrive,
NULL,
0,&dwVolumeSerialNumber,&dwMaximumComponentLength,&dwFileSystemFlags,szFileSystemNameBuffer,10
CreateResult
=
CreateFile(szFilePath,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_NEW,FILE
_ATTRIBUTE_NORMAL,NULL);
if(CreateResult == INVALID_HANDLE_VALUE)
break;
case DRIVE_REMOVABLE:
printf("The drive is a type that has removable media, for example, a floppy drive or removable hard
disk.\n ");
break;
case DRIVE_FIXED:
{ printf("创建文件失败!\n");
}
else
{ GetFileSizeEx(CreateResult,&liFileSize); printf("Create Success!\tThe File Size is:%d\n",liFileSize.QuadPart); CloseHandle(CreateResult); //SaveDataToFile(szFilePath,"This is a text!",lstrlen("This is a text!"));
if(hFileWrite == INVALID_HANDLE_VALUE)
{
printf("打开文件失败:%d\n",GetLastError());
}
SetFilePointer(hFileWrite,0,0,FILE_END);
if(WriteFile(hFileWrite,lpData,dwDataSize,&dwWriteDataSize,NULL))
} }
void SaveDataToFile(LPSTR szFilePath,LPVOID lpData,DWORD dwDataSize)
{
HABaidu NhomakorabeaDLE hFileWrite;
DWORD dwWriteDataSize;
hFileWrite
=
CreateFile(szFilePath,GENERIC_WRITE,0,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
printf("The drive is a type that cannot be removed, for example, a fixed hard drive.\n ");
break;
case DRIVE_RAMDISK:
printf("The drive is a RAM disk.\n ");
printf("\t No volume mount point found!\n"); //CreateDirectoryAndCreateFile(); CurrentDirectory(); MappingFile(); } else { printf("The first volume mount point is : %s\n",PtBuf); } } }
if(dwFileSystemFlags & FILE_SUPPORTS_REPARSE_POINTS) {
printf ("The file system does not support volume mount points.\n"); } if(dwFileSystemFlags & FILE_VOLUME_QUOTAS) {
{ printf("写文件成功,写如%d字节.\n",dwWriteDataSize);
}
CloseHandle(hFileWrite);
printf(" 空 闲 空 间 ( 字 节 ) :
\t\t%I64d\n",
(DWORD64)dwFreeClusters*(DWORD64)dwSectPerClust*(DWORD64)dwBytesPerSect);
printf("









:
\t\t%I64d",(DWORD64)dwTotalClusters*(DWORD64)dwSectPerClust*(DWORD64)dwBytesPerSect);
HANDLE hPt;
TCHAR PtBuf[MAX_PATH]; DWORD dwSysFlags; TCHAR FileSysNameBuf[MAX_PATH]; DWORD i = 0;
GetVolumeInformation(Buf,NULL,0,NULL,NULL,&dwSysFlags,FileSysNameBuf,MAX_PATH);
24);
printf ("\nVolume Serial Number is %u",dwVolumeSerialNumber); printf ("\nMaximum Component Length is %u",dwMaximumComponentLength); printf ("\nSystem Type is %s\n",szFileSystemNameBuffer);
printf("\n%s\n",szDrive);
uDriveType = GetDriveType(szDrive);
switch(uDriveType)
{
case DRIVE_NO_ROOT_DIR:
printf("The root path is invalid, for example, no volume is mounted at the path.\n ");
void main(void) {
CHAR szLogicalDriveStrings[1024]; PCHAR szDrive; ZeroMemory(szLogicalDriveStrings,1024); GetLogicalDriveStrings(1024-1,szLogicalDriveStrings); szDrive = (PCHAR)szLogicalDriveStrings; printf("磁盘:%s\n",szDrive); GetMountPoint(); } void GetDiskSpaceInfo(LPCSTR pszDrive) {
C语言系统编程资料:
#include <stdio.h> #include <windows.h> #include <stdlib.h> void GetDiskSpaceInfo(LPCSTR pszDrive); void GetDirverInfo(LPSTR szDrive); void DeleteMyFile(); void GetMountPoint(); void ProcessVolume(HANDLE hVol,TCHAR* Buf,DWORD iBufSize); void CreateDirectoryAndCreateFile(); void SaveDataToFile(LPSTR szFilePath,LPVOID lpData,DWORD dwDataSize); void CurrentDirectory(); void EnumerateFileInDrectory(LPSTR szPath); void ListAllFileInDrectory(LPSTR szPath); void ShowFileAttribute(LPSTR szPath); void ShowFileTime(PFILETIME lptime); void ShowFileSize(DWORD dwFileSizeHight,DWORD dwFileSizeLow); void ShowFileAttrInfo(DWORD dwAttribute); void MappingFile(); void MakeFileMapping(); void ReadFileMapping();
if(hVol == INVALID_HANDLE_VALUE) {
printf("No Volumes Found!\n"); } printf("FirstVolume:%s\n",buf); ProcessVolume(hVol,buf,MAX_PATH); }
void ProcessVolume(HANDLE hVol,TCHAR* Buf,DWORD iBufSize) {
if(bResult)
{
printf("\n使用GetDiskFreeSpace获取磁盘空间信息\n"); printf("空闲的簇数量: \t\t\t%d\n",dwFreeClusters);
printf("总簇数量: \t\t\t%d\n",dwTotalClusters);
printf("每簇的扇区数量: \t\t%d\n",dwSectPerClust); printf("每扇区的容量(字节): \t\t%d\n",dwBytesPerSect);
void CreateDirectoryAndCreateFile() {
LPSTR szDirPath = "C:\\gongfft"; LPSTR szFilePath = "C:\\gongfft\\gongfft.txt"; LARGE_INTEGER liFileSize; HANDLE CreateResult; CreateDirectory(szDirPath,NULL);
}
}
void GetDirverInfo(LPSTR szDrive)
{
UINT uDriveType;
DWORD dwVolumeSerialNumber;
DWORD dwMaximumComponentLength;
DWORD dwFileSystemFlags;
TCHAR szFileSystemNameBuffer[1024];
printf("...\n"); } void DeleteMyFile() {
DeleteFile("G:\\a.txt"); }
void GetMountPoint() {
TCHAR buf[MAX_PATH]; HANDLE hVol;
DWORD i = 0;
hVol = FindFirstVolume(buf,MAX_PATH);
if(!(dwSysFlags & FILE_SUPPORTS_REPARSE_POINTS)) {
printf("\tThis file system does not support volume mount points.\n"); } else {
hPt = FindFirstVolumeMountPoint(Buf,PtBuf,MAX_PATH); if(hPt == INVALID_HANDLE_VALUE) {
相关文档
最新文档