LoginSignup
0
0

More than 5 years have passed since last update.

VC++における論理ドライブの文字列出力

Posted at

使用関数

DWORD GetLogicalDriveStrings(
DWORD nBufferLength, // バッファのサイズ
LPTSTR lpBuffer // ドライブの文字列を格納するバッファ
);

戻り値
格納された文字列サイズ

コード

main.cpp
#include "stdafx.h"
#define MEM256 256

int SearchDrive() {
    TCHAR buf[MEM256];
    LPTSTR lp;
    CString drive;

    GetLogicalDriveStrings(sizeof(buf), buf);

    for (lp = buf; *lp != _T('\0'); lp++) {
        drive = lp;
        wprintf(drive + _T('\n'));
        lp += drive.GetLength();
    }
    return 0;
}
>C:\
>D:\

windowsは文字列が気持ち悪くて嫌いですね。
CStringにさえ落とし込めればあとはこっちのもの(雑)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0