win_setd.cpp
上传用户:dq031136
上传日期:2022-08-08
资源大小:802k
文件大小:1k
- #include <windows.h>
- #include <stdio.h>
- #include <stdlib.h>
- void main(void)
- {
- char szBuffer[MAX_PATH+100];
- UINT nDrive, AvailDrive = 0;
- int dwLogicalDrives = GetLogicalDrives();
- DWORD Success;
- printf("Number of logical drives: %dn", dwLogicalDrives);
- for (nDrive = 0; nDrive < 32; nDrive++)
- {
- if (dwLogicalDrives & (1 << nDrive))
- { // Is drive available?
- AvailDrive++;
- // Get disk information.
- wsprintf(szBuffer, "%c:\", nDrive+'A', ' ');
- // Print out information.
- if(SetCurrentDirectory(szBuffer))
- printf("%s Is Now Currentn", szBuffer);
- else
- printf("Could not set %s as the current driven", szBuffer);
- }
- }
- printf("Number of drives available: %dn", AvailDrive);
- }