procedure InitDriveNames;
var
  lst:TStrings;
  i:integer;
begin
  if edtDriveNames.text<>'' then exit;
  lst:=TStringList.create;
  try
    lst.text:=System.Shell.GetDriveList; //GetDriveList;
    if lst.count>0 then
      for i:=0 to lst.count-1 do  
        edtDriveNames.text:=edtDriveNames.text+lst.strings[i];
  finally
    lst.free;
  end;
end;

//读取配置
procedure InitIni;
var
  inifn:TIniFile;
begin
  edtInterval.text:=GetSetting('RefreshInterval','30');
  edtDriveNames.text:=UpperCase(GetSetting('DriveNames',''));
end;

//保存配置
procedure SaveIni;
begin
  SetSetting('DriveNames',edtDriveNames.text);
  SetSetting('RefreshInterval',edtInterval.text);
end;

//--- Widget设置窗口初始化事件，当打开Widget设置窗口时会触发此事件 ---
procedure OnSettingInit;
begin
  Beginupdate;
  InitIni;
  InitDriveNames;
  Endupdate;
end;

//--- 按下设置窗口的确定按钮时，触发此事件 ---
//通过设置返回值来改变是否允许确认,当result为False时不关闭设置窗口
function OnSettingClose(iResult);
var
  i:integer;
begin
  result:=true;
  try
    i:=StrToInt(edtInterval.text);
    if i<=0 then raise('');
  except
    showmsg('无效的刷新间隔时间！');
    //edtInterval.SetFocus;
    result:=false;
  end;
  if Result then
    SaveIni;
end;
