Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <stdio.h>
- int main(void){
- char const * fname = "test.txt";
- int err = 0;
- HANDLE file = CreateFile(fname,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
- if(file==INVALID_HANDLE_VALUE){
- fprintf(stderr,"Open of \"%s\" failed.\n",fname);
- return 1;
- }
- FILE_STORAGE_INFO fsi;
- if(GetFileInformationByHandleEx(
- file,
- FileStorageInfo,
- &fsi,
- sizeof(fsi) == 0))
- {
- fputs("GetFileInformationByHandleEx failed.\n",stderr);
- err = 1;
- goto quick_err;
- }
- printf("fsi.LogicalBytesPerSector: %lu\n"
- "fsi.PhysicalBytesPerSectorForAtomicity: %lu\n"
- "fsi.PhysicalBytesPerSectorForPerformance: %lu\n"
- "fsi.FileSystemEffectivePhysicalBytesPerSectorForAtomicity: %lu\n"
- "fsi.Flags: %lu\n"
- "fsi.ByteOffsetForSectorAlignment: %lu\n"
- "fsi.ByteOffsetForPartitionAlignment: %lu\n",
- fsi.LogicalBytesPerSector,
- fsi.PhysicalBytesPerSectorForAtomicity,
- fsi.PhysicalBytesPerSectorForPerformance,
- fsi.FileSystemEffectivePhysicalBytesPerSectorForAtomicity,
- fsi.Flags,
- fsi.ByteOffsetForSectorAlignment,
- fsi.ByteOffsetForPartitionAlignment);
- long spc;
- long bps;//
- long nfc;
- long tnc;
- if(GetDiskFreeSpaceW(NULL,&spc,&bps,&nfc,&tnc)==0){
- fputs("GetFreeSpaceW failed.\n",stderr);
- err = 1;
- goto quick_err;
- }
- printf("spc: %ld\nbps: %ld\nnfc: %ld\ntnc: %ld\n",spc,bps,nfc,tnc);
- quick_err:
- CloseHandle(file);
- return err;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement