04-28 14:02
Notice
Recent Posts
Recent Comments
관리 메뉴

Scientific Computing & Data Science

[C/C++] MFC / 시스템의 드라이브 정보 표시 본문

Programming/C&C++

[C/C++] MFC / 시스템의 드라이브 정보 표시

cinema4dr12 2015. 1. 2. 13:21

MFC에서 논리 드라이브에 대한 정보를 표시하는 방법은 다음과 같다:


[Header File]

CComboBox m_wndDevices;
CEdit m_wndVolume;
CEdit m_wndFileSys;
CEdit m_wndMaxLen;


[Source Code]

CString s;
CString sRootPathName;
CString sVolumeName;
DWORD dwVolumeSerialNumber;
DWORD dwMaxComponentLength;
DWORD dwFileSystemFlags;
CString sFileSystemName;

m_wndDevices.GetWindowText(s);
sRootPathName.Format(_T("%s\\"), s);

BOOL bSuccess = ::GetVolumeInformation(sRootPathName,
	sVolumeName.GetBufferSetLength(MAX_PATH+1), MAX_PATH+1,
	&dwVolumeSerialNumber, &dwMaxComponentLength, &dwFileSystemFlags,
	sFileSystemName.GetBufferSetLength(MAX_PATH+1), MAX_PATH+1);

// Note: These lines should be used to restore the strings
sVolumeName.ReleaseBuffer();
sFileSystemName.ReleaseBuffer();

m_wndPath.SetWindowText(sRootPathName);
if (bSuccess)
{
	m_wndVolume.SetWindowText(sVolumeName);
	m_wndFileSys.SetWindowText(sFileSystemName);
	s.Format(_T("%u"), dwMaxComponentLength);
	m_wndMaxLen.SetWindowText(s);
}
else
{
	s = _T("Volume Unavailable");
	m_wndVolume.SetWindowText(s);
	m_wndFileSys.SetWindowText(s);
	m_wndMaxLen.SetWindowText(s);
}


[Result]


Comments