系统相关
首页 > 系统相关> > 获取windows系统盘符

获取windows系统盘符

作者:互联网

#include #include int main(){ wchar_t LogicalDrivers[MAX_PATH]={0}; DWORD r=GetLogicalDriveStringsW(MAX_PATH, LogicalDrivers); if(r==0){ wprintf(L"failed to get drive namespace %ld", GetLastError()); } if(r>0 && r<=MAX_PATH){ wchar_t *SingleDrive=LogicalDrivers; while(*SingleDrive){ wprintf(L"%ls\n", SingleDrive); SingleDrive+=wcslen(SingleDrive)+1;//因为GetLogicalDriveStringsW()会将获取到的盘符C:\ D:\...放入缓冲区中,并且每个盘符后面放入一个'\0', 所以不能用SingleDrive++这样的方式 } } return 0; }

标签:ld,LogicalDrivers,windows,MAX,盘符,获取,wprintf,PATH,include
来源: https://www.cnblogs.com/zhis-/p/14971795.html