terça-feira, 21 de maio de 2013
C++ | Devolver todas as letras dos discos físicos (fixos) e removíveis em Windows
//Todos os discos físicos, com message box:
for each (DriveInfo ^drive in DriveInfo::GetDrives()) {
if (drive->DriveType == DriveType::Fixed)
//Mensagem
MessageBox::Show(drive->Name,
"My Application", MessageBoxButtons::OKCancel,
MessageBoxIcon::Asterisk);
}
//Todos os discos removíveis, com mensagem na consola:
for each (DriveInfo ^drive in DriveInfo::GetDrives()) {
if (drive->DriveType == DriveType::Removable)
//Mensagem
Console::WriteLine("{0} this is a fixed drive...", drive->Name);
}
//Não se esqueçam dos namespaces no início. Estes são os que estou a usar:
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::IO;
Subscrever:
Enviar feedback (Atom)
Sem comentários:
Enviar um comentário