Procedure initial();
  function  CheckDevice(DevStr:String):boolean;
  function  CheckBluetooth():boolean;
  Procedure Reinitial();
  function  Find_Device(Dev_string:PCHAR):boolean;stdcall;external 'FindDev.dll';
  function  InitializeWinIo: boolean; stdcall; external 'fn.dll';  procedure ShutdownWinIo; stdcall; external 'fn.dll';
  function  GetPortVal(wPortAddr: DWORD; pdwPortVal: PDWORD; bSize: BYTE):
            boolean; stdcall; external 'fn.dll';
  function  SetPortVal(wPortAddr: DWORD; dwPortVal: DWORD; bSize: BYTE):
            boolean; stdcall; external 'fn.dll';
  procedure RemoveWinIoDriver; stdcall; external 'fn.dll';implementation{$R *.dfm}
//{$APPTYPE CONSOLE}procedure TForm_main.FormCreate(Sender: TObject);
var
  ThreadId:DWORD;
begin
  case GetSystemDefaultLangID of//check language
    $0804:
    begin       //中文
      panel1.Caption:='正在检查计算机设备......';
    end
    else
    begin    //英文
      panel1.Caption:='Checking device status';
    end;
  end;   case GetSystemDefaultLangID of//check language
    $0804: Label5.Caption:='建议:请在安装驱动后重新启动电脑!           ';
    else   Label5.Caption:='Advice:Restart computer after you install a driver!       ';
  end;  currentfocus:=-1;
  CreateThread(nil,0,@initial, nil,0,ThreadId);
  CheckDBCLKTimer:= TTimer.Create(Self);
  CheckDBCLKTimer.Interval :=2500;
  CheckDBCLKTimer.Enabled := TRUE;
  CheckDBCLKTimer.OnTimer := Tpontimer;
end;procedure TForm_main.TpbtmouseEnter(Sender: TObject);
var
  i:integer;
begin
  if not CheckComplete then exit;
  for i:=0 to TpCaption.Count-1 do
  begin
    if TLabel(sender).Tag = i then
    begin
    Tpbt[i].Transparent := false;
    Tpbt[i].Font.Color:=clwhite;
    currentfocus:= i;
    end
    else
    begin
      Tpbt[i].Transparent := true;
      Tpbt[i].Font.Color:=clgray
    end;
  end;
end;procedure TForm_main.TpbtmouseLeave(Sender: TObject);
var
i:integer;
begin
  if not CheckComplete then exit;
  for i:=0 to TpCaption.Count-1 do
  begin
    if TLabel(sender).Tag = i then
    begin
    Tpbt[i].Transparent := true;
    Tpbt[i].Font.Color:=clgray;
    currentfocus:= -1;
    end;
  end;
end;
procedure TForm_main.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if not CheckComplete then exit;
  if (Key = 40) or (Key = 39) then
  begin
   if currentfocus<TpCaption.Count-1 then
   currentfocus:=currentfocus+1
   else
   currentfocus:=0;
   TLabel(sender).Tag:=currentfocus;
   TpbtmouseEnter(Tlabel(sender));
  end;  if (Key = 38) or (key = 37) then
  begin
    if currentfocus>0 then
      currentfocus:=currentfocus-1
    else
      currentfocus:=TpCaption.Count-1 ;
    TLabel(sender).Tag:=currentfocus;
    TpbtmouseEnter(Tlabel(sender));
  end;  if key = 13 then
  begin
    TLabel(sender).Tag:=currentfocus;
    TpbtCllik(Tlabel(Sender));
  end;   if key  = vk_tab then
   begin
    if currentfocus<TpCaption.Count-1 then
      currentfocus:=currentfocus+1
    else
      currentfocus:=0;
    TLabel(sender).Tag:=currentfocus;
    TpbtmouseEnter(Tlabel(sender));
  end;
end;Procedure initial();
Var
  i:integer;
  osver: byte;
begin
  CheckComplete:=false;
  AllSection:= TStringlist.Create;
  TpCaption:= TStringlist.Create;
  DriverPath:=TStringList.Create;
  osver:=Getversion;
  courrentpath :=ExtractFilePath(Paramstr(0));
  if osver<6 then                   //小于6的为xp系统,大于等于6的为win7系统
  begin
    case GetSystemDefaultLangID of//check language
      $0804:IniFile:=TIniFile.Create(courrentpath+'\Config\TPDRVCDXP_CN.INI');
      $0411:IniFile:=TIniFile.Create(courrentpath+'\Config\TPDRVCDXP_JP.INI');
    else
            IniFile:=TIniFile.Create(courrentpath+'\Config\TPDRVCDXP_EN.INI');    end;
  end
  else begin
    case GetSystemDefaultLangID of//check language
      $0804:IniFile:=TIniFile.Create(courrentpath+'\Config\TPDRVCDVISTA_CN.INI');
      $0411:IniFile:=TIniFile.Create(courrentpath+'\Config\TPDRVCDVISTA_JP.INI');
    else
            IniFile:=TIniFile.Create(courrentpath+'\Config\TPDRVCDVISTA_EN.INI');
    end;
  end;
  inifile.ReadSections(AllSection);           //ini字串
  for i:=0 to allsection.Count-1 do //strings的属性:包含的字符串的个数
  begin
    if Pos('OPTION_',AllSection.Strings[i])>0 then
    begin
      optionCount:=optionCount+1;   //带option的个数一般好像只有ccenter没有
    end;
  end;
  for i := 0 to optionCount-1 do
  begin
    if  inifile.ReadString(AllSection.Strings[i],'STATUS','HIDE') = 'SHOW' then
    begin
      TpCaption.Add(inifile.ReadString(AllSection.Strings[i],'CAPTION','Unknown'));
      DriverPath.Add(inifile.ReadString(AllSection.Strings[i],'PATH',''))
    end;    if  inifile.ReadString(AllSection.Strings[i],'STATUS','HIDE') = 'CHECK' then
    begin
      if CheckDevice(AllSection.Strings[i]) then
      begin
        TpCaption.Add(inifile.ReadString(AllSection.Strings[i],'CAPTION','Unknown'));
        DriverPath.Add(inifile.ReadString(AllSection.Strings[i],'PATH',''))
      end;
    end;
  end;
  {for i:=0 to TpCaption.Count-1 do     //窗口中字串
  begin
    Tpbt[i]:= Tlabel.Create(form_main);//创建驱动按钮
    Tpbt[i].Parent    := form_main;
    Tpbt[i].Width     := 103;
    Tpbt[i].Height    := 20;
    Tpbt[i].Top       := 50+Tpbt[i].Height*i;
    Tpbt[i].Left      := 20;
    Tpbt[i].AutoSize  := false;
    Tpbt[i].Color     :=  rgb(inifile.ReadInteger('Pane','BackFocusColorR',$C8),
                        inifile.ReadInteger('Pane','BackFocusColorG',$CA),
                        inifile.ReadInteger('Pane','BackFocusColorB',$D2));    Tpbt[i].Transparent := true;
    Tpbt[i].Cursor      := crHandPoint;
    Tpbt[i].Layout      := tlCenter;
    Tpbt[i].Font.Charset:= DEFAULT_CHARSET;
    Tpbt[i].Font.Color  := clgray;    Tpbt[i].Font.Size   := 9;
    if inifile.ReadString('Pane','FontBold','NO')='YES' then
    Tpbt[i].Font.Style  := [fsBold];
    Tpbt[i].Caption     := TpCaption.Strings[i];
    Tpbt[i].Tag         := i;
    tpbt[i].OnMouseEnter :=Form_main.TpbtmouseEnter;
    Tpbt[i].OnMouseLeave :=Form_main.TpbtmouseLeave;
    Tpbt[i].OnClick      :=Form_main.TpbtCllik;
  end;  Form_main.Panel1.Visible:=false; //检测设备的那个框  form_main.Lb_app.Top :=  tpbt[TpCaption.Count-1].Top+40;   //应用程序:
  form_main.Lb_app1.Top :=  tpbt[TpCaption.Count-1].Top+60;  //控制中心()
  form_main.Lb_app.Caption := inifile.ReadString('APP','TITLE','Application');
  form_main.Lb_app1.Caption := inifile.ReadString('APP','Caption','Control Center(Recommended)'); }
  //无manual 要的话可在此添加
  CheckComplete:=true;
  Form_main.Timer1.Enabled:=false;
  Form_main.Timer2.Enabled:=true;
  ExitThread(0);
end;procedure TForm_main.TpbtCllik(Sender: TObject);
var
  i:integer;
begin
  if not CheckComplete then exit;
  for i:=0 to TpCaption.Count-1 do
  begin
    if TLabel(sender).Tag = i then
    begin
      TpCMD(i);
    end;
  end;
end;
procedure TForm_main.TpCMD(panenum: integer);
var
  tmpstr:string;
  i:integer;
  dirLength:integer;
  Directory:array [1..255] of char;
begin
  dirLength:=255;
  for i:= 1 to 255 do
  begin
    Directory[i]:=#0;
  end;
  if not DBclk then
  begin
  DBclk:= TRUE;
  CheckDBCLKTimer.Enabled := true;
    try
      sysutils.SetCurrentDir(courrentpath);
      tmpstr:=courrentpath+DriverPath.Strings[panenum];
      for i:= length(tmpstr) downto 1 do
      begin
        if tmpstr[i]='\' then
        begin
          dirLength:=i;
          break;
        end;
      end;
      for i:=1 to dirLength do
      begin
        Directory[i]:=tmpstr[i];
      end;
      tmpstr:=TrimRight(Directory); //这一段搞 tmpstr 好像没啥用      ShellExecute(Handle,'open',Pchar(courrentpath+DriverPath.Strings[panenum]),nil,Pchar(tmpstr),SW_SHOW)
    except
    DBclk:=False;
    CheckDBCLKTimer.Enabled := true;
    end;
  end;
end;procedure TForm_main.CNKeyDown(var Message: TWMKeyDown);
begin
  //屏蔽掉父辈的CNKeyDown处理 使响应tab的  keydown
end;

解决方案 »

  1.   

    procedure TForm_main.Tpontimer(Sender: TObject);
    begin
      DBclk:=false;
      CheckDBCLKTimer.Enabled := false;
    end;function CheckDevice(DevStr: String): boolean;
    begin
      Result:=False;
      if DevStr = 'OPTION_MODEM' then
      begin
        If Find_Device('MODEM') then
        begin
          dycheckmodem:=false;
          Result:=true;
        end
        else
        begin
          dycheckmodem:=true;
          Result:=False;
        end;
      end;
      if DevStr = 'OPTION_3GMODULE' then
      begin
        Result:=Find_Device('3GMODULE');
      end;  
      if DevStr = 'OPTION_CARDREADER' then
      begin
        Result:=Find_Device('CARDREADER');
      end;
      if DevStr = 'OPTION_BLUETOOTH' then
      begin
        Result:=Find_Device('BLUETOOTH');
      end;
      if DevStr = 'OPTION_CAMERA' then
      begin
        Result:=Find_Device('CAMERA');
      end;
      if DevStr = 'OPTION_TVCARD' then
      begin
        Result:=False;
      end;
      if DevStr = 'OPTION_WIRELESS' then
      begin
        Result:=Find_Device('WIRELESS');
      end;
      if DevStr = 'OPTION_MASSSTORAGE' then
      begin
        Result:=Find_Device('MASSSTORAGE');
      end;
      if DevStr = 'OPTION_TPM' then
      begin
        Result:=Find_Device('TPM');
      end;
      if DevStr = 'OPTION_ROBSON' then
      begin
        Result:=Find_Device('ROBSON');
      end;
      if DevStr = 'OPTION_FINGERMARK' then
      begin
        Result:=Find_Device('FINGERMARK');
      end;
      if DevStr = 'OPTION_TOUCHPANEL' then
      begin
        Result:=Find_Device('TOUCHPANEL');
      end;
      if DevStr = 'OPTION_MEI' then
      begin
        Result:=Find_Device('MEI');
      end;
      if DevStr = 'OPTION_INTEL' then
      begin
        Result:=Find_Device('INTEL');
      end;
      if DevStr = 'OPTION_NVIDIA' then
      begin
        Result:=Find_Device('NVIDIA');
      end;
      if DevStr = 'OPTIOM_DISPALY' then
      begin
        Result:=Find_Device('DISPLAY');
      end;
      if DevStr = 'OPTION_LAN' then
      begin
        Result:=Find_Device('LAN');
      end;
      if DevStr = 'OPTION_WIRELESS/BLUETOOTH' then
      begin
        Result:=Find_Device('WIRELESS/BLUETOOTH');
      end;
    end;function CheckBluetooth():boolean;
    var
      data:DWORD;
    begin
      InitializeWinIo;
      result:=false;
      SetPortVal($72,$5E,1);
      GetPortVal($73,@data,1);
      if (data and $10) = $10 then
      result:=true;
      ShutdownWinIo;
    end;Procedure Reinitial();
    var
      ThreadId:Dword;
      i:integer;
    begin
      if not CheckComplete then exit;  for i:=0 to TpCaption.Count-1 do
      begin
        Tpbt[i].Destroy;
      end;
      AllSection := TStringlist.Create;
      TpCaption := TStringlist.Create;
      DriverPath :=TStringList.Create;  currentfocus := -1;
      optionCount := 0;
      CreateThread(nil,0,@initial, nil,0,ThreadId);
    end;procedure TForm_main.Timer1Timer(Sender: TObject);
    begin
      if Find_Device('MODEM') and dycheckmodem then
      begin
        Reinitial;
        dycheckmodem:=False;
        Timer1.Enabled:=false;
      end;
    end;procedure TForm_main.Label1Click(Sender: TObject);
    begin
      ShellExecute(Handle,'open',pchar(courrentpath),nil,nil,SW_SHOW)
    end;procedure TForm_main.Label2Click(Sender: TObject);
    begin
      Close;
    end;procedure TForm_main.Label1MouseEnter(Sender: TObject);
    begin
      label1.Font.Color:=clgray;
    end;procedure TForm_main.Label1MouseLeave(Sender: TObject);
    begin
      label1.Font.Color:=clblack;
    end;procedure TForm_main.Label2MouseEnter(Sender: TObject);
    begin
      label2.Font.Color:=clgray;
    end;procedure TForm_main.Label2MouseLeave(Sender: TObject);
    begin
      label2.Font.Color:=clblack;
    end;procedure TForm_main.Lb_app1MouseLeave(Sender: TObject);
    begin
      lb_app1.Transparent:=true;
    end;procedure TForm_main.Lb_app1Click(Sender: TObject);
    begin
      shellExecute(Handle,'open',pchar(courrentpath+'ControlCenter\Setup.exe'),nil,nil,SW_SHOW);
    end;procedure TForm_main.Lb_app1MouseEnter(Sender: TObject);
    begin
      lb_app1.Transparent:=false;
      lb_app1.Color:=rgb($C8,$CA,$D2);
    end;procedure TForm_main.Timer2Timer(Sender: TObject);
    var
      i:integer;
    begin
      Form_main.Timer2.Enabled:=false;
      for i:=0 to TpCaption.Count-1 do     //窗口中字串
      begin
        Tpbt[i]:= Tlabel.Create(form_main);//创建驱动按钮
        Tpbt[i].Parent    := form_main;
        Tpbt[i].Width     := 103;
        Tpbt[i].Height    := 20;
        Tpbt[i].Top       := 50+Tpbt[i].Height*i;
        Tpbt[i].Left      := 20;
        Tpbt[i].AutoSize  := false;
        Tpbt[i].Color     :=  rgb(inifile.ReadInteger('Pane','BackFocusColorR',$C8),
                            inifile.ReadInteger('Pane','BackFocusColorG',$CA),
                            inifile.ReadInteger('Pane','BackFocusColorB',$D2));    Tpbt[i].Transparent := true;
        Tpbt[i].Cursor      := crHandPoint;
        Tpbt[i].Layout      := tlCenter;
        Tpbt[i].Font.Charset:= DEFAULT_CHARSET;
        Tpbt[i].Font.Color  := clgray;    Tpbt[i].Font.Size   := 9;
        if inifile.ReadString('Pane','FontBold','NO')='YES' then
        Tpbt[i].Font.Style  := [fsBold];
        Tpbt[i].Caption     := TpCaption.Strings[i];
        Tpbt[i].Tag         := i;
        tpbt[i].OnMouseEnter :=Form_main.TpbtmouseEnter;
        Tpbt[i].OnMouseLeave :=Form_main.TpbtmouseLeave;
        Tpbt[i].OnClick      :=Form_main.TpbtCllik;
      end;  Form_main.Panel1.Visible:=false; //检测设备的那个框  form_main.Lb_app.Top :=  tpbt[TpCaption.Count-1].Top+40;   //应用程序:
      form_main.Lb_app1.Top := tpbt[TpCaption.Count-1].Top+60;  //控制中心()
    //  form_main.Lb_app2.Top := tpbt[TpCaption.Count-1].Top+90;   //摄像头()
      form_main.Lb_app3.Top := tpbt[TpCaption.Count-1].Top+90;  //HotFix()
      form_main.Lb_app.Caption := inifile.ReadString('APP','TITLE','Application');
      form_main.Lb_app1.Caption := inifile.ReadString('APP','Caption','ControlCenter (Recommended)');
    //  form_main.Lb_app2.Caption := inifile.ReadString('APP','HEAD','Camera (Recommended)');
      form_main.Lb_app3.Caption := inifile.ReadString('APP','LEMMA','HotFix (Recommended)');  //无manual 要的话可在此添加
      CheckComplete:=true;
    end;procedure TForm_main.Lb_app2Click(Sender: TObject);
    begin
    //  shellExecute(Handle,'open',pchar(courrentpath+'CameraApp\Setup.exe'),nil,nil,SW_SHOW);
    end;procedure TForm_main.Lb_app2MouseEnter(Sender: TObject);
    begin
    //  lb_app2.Transparent:=false;
    //  lb_app2.Color:=rgb($C8,$CA,$D2);
    end;procedure TForm_main.Lb_app2MouseLeave(Sender: TObject);
    begin
    //  lb_app2.Transparent:=true;
    end;procedure TForm_main.Lb_app3Click(Sender: TObject);
    begin
      shellExecute(Handle,'open',pchar(courrentpath+'HotFix\Windows6.1-KB2566191-x86.msu'),nil,nil,SW_SHOW)
    end;procedure TForm_main.Lb_app3MouseLeave(Sender: TObject);
    begin
      lb_app3.Transparent:=true;
    end;procedure TForm_main.Lb_app3MouseEnter(Sender: TObject);
    begin
      lb_app3.Transparent:=false;
      lb_app3.Color:=rgb($C8,$CA,$D2);
    end;end.