Added "autodetect" drive type option.

This commit is contained in:
Alexandre Julliard 2005-10-20 13:16:46 +00:00
parent 9c6a15ce62
commit c02356b835
2 changed files with 44 additions and 17 deletions

View file

@ -146,6 +146,34 @@ static void set_drive_type( char letter, DWORD type )
}
}
static DWORD get_drive_type( char letter )
{
HKEY hKey;
char driveValue[4];
DWORD ret = DRIVE_UNKNOWN;
sprintf(driveValue, "%c:", letter);
if (RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Wine\\Drives", &hKey) != ERROR_SUCCESS)
WINE_TRACE(" Unable to open Software\\Wine\\Drives\n" );
else
{
char buffer[80];
DWORD size = sizeof(buffer);
if (!RegQueryValueExA( hKey, driveValue, NULL, NULL, (LPBYTE)buffer, &size ))
{
WINE_TRACE("Got type '%s' for %s\n", buffer, driveValue );
if (!strcasecmp( buffer, "hd" )) ret = DRIVE_FIXED;
else if (!strcasecmp( buffer, "network" )) ret = DRIVE_REMOTE;
else if (!strcasecmp( buffer, "floppy" )) ret = DRIVE_REMOVABLE;
else if (!strcasecmp( buffer, "cdrom" )) ret = DRIVE_CDROM;
}
RegCloseKey(hKey);
}
return ret;
}
#if 0
/* currently unused, but if users have this burning desire to be able to rename drives,
@ -279,7 +307,7 @@ void load_drives()
snprintf(serialstr, sizeof(serialstr), "%lX", serial);
WINE_TRACE("serialstr: '%s'\n", serialstr);
add_drive(*devices, targetpath, volname, serialstr, GetDriveType(rootpath));
add_drive(*devices, targetpath, volname, serialstr, get_drive_type(devices[0]) );
len -= strlen(devices);
devices += strlen(devices);

View file

@ -139,13 +139,14 @@ struct drive_typemap {
};
static const struct drive_typemap type_pairs[] = {
{ DRIVE_UNKNOWN, "Autodetect" },
{ DRIVE_FIXED, "Local hard disk" },
{ DRIVE_REMOTE, "Network share" },
{ DRIVE_REMOVABLE, "Floppy disk" },
{ DRIVE_CDROM, "CD-ROM" }
};
#define DRIVE_TYPE_DEFAULT 1
#define DRIVE_TYPE_DEFAULT 0
static void fill_drive_droplist(long mask, char curletter, HWND dialog)
{
@ -447,24 +448,20 @@ static void update_controls(HWND dialog)
/* drive type */
type = current_drive->type;
if (type)
SendDlgItemMessage(dialog, IDC_COMBO_TYPE, CB_RESETCONTENT, 0, 0);
for (i = 0; i < sizeof(type_pairs) / sizeof(struct drive_typemap); i++)
{
SendDlgItemMessage(dialog, IDC_COMBO_TYPE, CB_RESETCONTENT, 0, 0);
for (i = 0; i < sizeof(type_pairs) / sizeof(struct drive_typemap); i++)
SendDlgItemMessage(dialog, IDC_COMBO_TYPE, CB_ADDSTRING, 0, (LPARAM) type_pairs[i].sDesc);
if (type_pairs[i].sCode == type)
{
SendDlgItemMessage(dialog, IDC_COMBO_TYPE, CB_ADDSTRING, 0, (LPARAM) type_pairs[i].sDesc);
if (type_pairs[i].sCode == type)
{
selection = i;
}
selection = i;
}
}
if (selection == -1) selection = DRIVE_TYPE_DEFAULT;
SendDlgItemMessage(dialog, IDC_COMBO_TYPE, CB_SETCURSEL, selection, 0);
} else WINE_WARN("no Type field?\n");
if (selection == -1) selection = DRIVE_TYPE_DEFAULT;
SendDlgItemMessage(dialog, IDC_COMBO_TYPE, CB_SETCURSEL, selection, 0);
/* removeable media properties */
label = current_drive->label;
@ -811,7 +808,9 @@ DriveDlgProc (HWND dialog, UINT msg, WPARAM wParam, LPARAM lParam)
selection = SendDlgItemMessage(dialog, IDC_COMBO_TYPE, CB_GETCURSEL, 0, 0);
if (selection == 2 || selection == 3) /* cdrom or floppy */
if (selection >= 0 &&
(type_pairs[selection].sCode == DRIVE_CDROM ||
type_pairs[selection].sCode == DRIVE_REMOVABLE))
{
if (IsDlgButtonChecked(dialog, IDC_RADIO_AUTODETECT))
mode = BOX_MODE_CD_AUTODETECT;