Skip to content

Commit 99bcdaf

Browse files
committed
Add isdrive: drive type detection
1 parent d53c70a commit 99bcdaf

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

isdrive.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#ifndef UNICODE
2+
#define UNICODE
3+
#define _UNICODE
4+
#endif
5+
#include <stdlib.h>
6+
#include <stdio.h>
7+
#include <windows.h>
8+
#ifdef __TINYC__
9+
LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR,int*);
10+
BOOL WINAPI PathStripToRootW(wchar_t*);
11+
BOOL WINAPI PathIsRootW(wchar_t*);
12+
#else
13+
#include <shellapi.h>
14+
#include <setupapi.h>
15+
#endif
16+
17+
int main (int argc,char *argv[]) {
18+
wchar_t root[1000];
19+
unsigned int type;
20+
unsigned int i;
21+
if( argc < 2 )
22+
GetCurrentDirectoryW(sizeof(root),root);
23+
else {
24+
wchar_t** wargv = CommandLineToArgvW (GetCommandLineW(), &argc);
25+
wcscpy(root,wargv[1]);
26+
}
27+
if (GetDriveTypeW(root) == 1) {
28+
if (!PathStripToRootW(root))
29+
return 1;
30+
}
31+
switch (GetDriveTypeW(root)) {
32+
case (2) : printf("REMOVABLE\n"); break;
33+
case (3) : printf("FIXED\n"); break;
34+
case (4) : printf("REMOTE\n"); break;
35+
case (5) : printf("CDROM\n"); break;
36+
case (6) : printf("RAMDISK\n"); break;
37+
}
38+
return 1;
39+
}

minbin/isdrive.exe

2 KB
Binary file not shown.

0 commit comments

Comments
 (0)