2 * LABEL.C - label internal command.
7 * 10-Dec-1998 (Eric Kohl)
10 * 11-Dec-1998 (Eric Kohl)
13 * 19-Jan-1998 (Eric Kohl)
16 * 28-Apr-2005 (Magnus Olsen <magnus@greatlord.com>)
17 * Remove all hardcoded strings in En.rc
22 #ifdef INCLUDE_CMD_LABEL
25 INT
cmd_label (LPTSTR param
)
27 TCHAR szRootPath
[] = _T("A:\\");
32 /* set empty label string */
33 szLabel
[0] = _T('\0');
38 if (!_tcsncmp (param
, _T("/?"), 2))
40 ConOutResPaging(TRUE
,STRING_LABEL_HELP1
);
45 if (param
[0] != _T('\0') && param
[1] == _T(':'))
47 szRootPath
[0] = toupper(*param
);
49 while (_istspace(*param
))
54 /* get label of current drive */
55 TCHAR szCurPath
[MAX_PATH
];
56 GetCurrentDirectory (MAX_PATH
, szCurPath
);
57 szRootPath
[0] = szCurPath
[0];
60 _tcsncat(szLabel
, param
, 79);
63 if (!IsValidPathName (szRootPath
))
65 error_invalid_drive ();
70 if (szLabel
[0] == _T('\0'))
72 GetVolumeInformation(szRootPath
, szOldLabel
, 80, &dwSerialNr
,
75 /* print drive info */
76 if (szOldLabel
[0] != _T('\0'))
78 ConOutResPrintf(STRING_LABEL_HELP2
, _totupper(szRootPath
[0]), szOldLabel
);
82 ConOutResPrintf(STRING_LABEL_HELP3
, _totupper(szRootPath
[0]));
85 /* print the volume serial number */
86 ConOutResPrintf(STRING_LABEL_HELP4
, HIWORD(dwSerialNr
), LOWORD(dwSerialNr
));
88 ConOutResPuts(STRING_LABEL_HELP5
);
90 ConInString(szLabel
, 80);
93 if (!SetVolumeLabel(szRootPath
, szLabel
))
95 ConOutFormatMessage(GetLastError());
103 #endif /* INCLUDE_CMD_LABEL */