jamie
jamie

Reputation: 590

How do I check if a Visual C++ argument is a valid drive letter?

Like the title says, I have a C++ program and the user passes in an argument. I want to validate whether the argument passed is a valid DOS/Windows drive letter (i.e. C:. D:. E:) and that the drive exists on the system. How do I do this?

Upvotes: 1

Views: 3940

Answers (1)

Martin Beckett
Martin Beckett

Reputation: 96167

You can get the type of a drive with GetDriveType() - which also tells you if a drive doesn't exist or isn't availble

Or the 'correct' way is to enumerate through all the drives

Upvotes: 6

Related Questions