C++ window system to obtain computer disk and capacity


foreword

This article mainly encapsulates a convenient function: used to obtain disk-related information on the window system

1. Principle introduction

Generally for disks, we only need two functions:

  1. Get which disks are on the current computer
  2. Perhaps what is the current capacity of each disk

In order to satisfy these two functions, we need to use two API functions:

  1. GetLogicalDrives: Get which disks the current computer has
  2. GetDiskFreeSpaceExA: Get the capacity of a specific disk

These two functions are relatively simple, the first is the first function GetLogicalDrives

Just call it directly

DWORD GetLogicalDrives();

Guess you like

Origin blog.csdn.net/weixin_50964512/article/details/131358041