#include #include int main() { DWORD drives = GetLogicalDriveStringsW(0, NULL); // ワイド文字列用の関数を使用する if (drives == 0) { fprintf(stderr, "GetLogicalDriveStringsW failed (%lu)\n", GetLastError()); return 1; } wchar_t* buffer = (wchar_t*)malloc(drives * sizeof(wchar_t)); // ワイド文字列用のバッファを確保 if (buffer == NULL) { fprintf(stderr, "Memory allocation failed\n"); return 1; } if (GetLogicalDriveStringsW(drives, buffer)) { wchar_t* currentDrive = buffer; while (*currentDrive) { wprintf(L"Drive: %s\n", currentDrive); currentDrive += wcslen(currentDrive) + 1; } } else { fprintf(stderr, "GetLogicalDriveStringsW failed (%lu)\n", GetLastError()); } free(buffer); return 0; }