unit wizard;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, StdCtrls, ExtCtrls, jpeg, Registry, CheckLst, LPL_Sysutils, filter;

type
  TForm2 = class(TForm)
    Panel2: TPanel;
    Image1: TImage;
    Bevel2: TBevel;
    next: TButton;
    back: TButton;
    quit: TButton;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    TabSheet2: TTabSheet;
    Label4: TLabel;
    Label5: TLabel;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox3: TCheckBox;
    PageControl2: TPageControl;
    TabSheet3: TTabSheet;
    TabSheet4: TTabSheet;
    Genchklist: TCheckListBox;
    Vischklist: TCheckListBox;
    TabSheet5: TTabSheet;
    Label6: TLabel;
    Label7: TLabel;
    TabSheet6: TTabSheet;
    Label8: TLabel;
    Label9: TLabel;
    Memo1: TMemo;
    TabSheet7: TTabSheet;
    procedure FormCreate(Sender: TObject);
    procedure quitClick(Sender: TObject);
    procedure nextClick(Sender: TObject);
    procedure PageControl1Change(Sender: TObject);
  private
    { Private declarations }
  public
    Procedure SetPage0;
    Procedure SetPage1;
    Procedure SetPage2;
    Procedure SetPage3;
    Procedure SetPage4;
  end;

var
  Form2: TForm2;

implementation

uses CM2PlugInTypes, Unit1;

{$R *.dfm}

function CPUname: string; 
var 
  Reg: TRegistry;
  S: String;
  Ok: Boolean;
begin
  S := '';
  Reg := TRegistry.Create;
  try
    Reg.RootKey := HKEY_LOCAL_MACHINE;
    if Reg.OpenKey('\Hardware\Description\System\CentralProcessor\0', False) then
      S := Reg.ReadString('ProcessorNameString');
  finally
    Reg.Free;
  end;
  Ok := False;
  Repeat
   If length(s) = 0 then begin
    ok := true;
   end
    else
   begin
    If S[1] <> ' ' then begin
     OK := true;
    End
     else
    begin
     S := Copy(S, 2, length(S));
    end;
   end;
  until Ok;
  Result := S;
end;

Procedure AddThis(What: String);
Begin
 Form2.Memo1.lines.Add(GetFilt(What, 1, 'q') + ': ' + GetFilt(What, 2, 'q'));
End;

procedure GetOSVerInfo;
var
  VI: TOSVersionInfo;
  S: STring;
  MS: TMemoryStatus;
begin
  S := '';
  MS.dwLength := SizeOf(TMemoryStatus);
  GlobalMemoryStatus(MS);
  if (Win32Platform = VER_PLATFORM_WIN32_WINDOWS) or
    (Win32Platform = VER_PLATFORM_WIN32_NT) then
  begin
    if Win32CSDVersion <> '' then
      S := ' (' + Win32CSDVersion + ')';
  end;

  VI.dwOSVersionInfoSize := SizeOf(VI);
  GetVersionEx(VI);
  AddThis(Format(SBuildNo, [LoWord(VI.dwBuildNumber)]) + S);
end;

procedure GetSysInfo;
var
  SI: TSystemInfo;
  MS: TMemoryStatus;
begin
  GetSystemInfo(SI);
  with SI do
  begin
{    AddThis(Format(SProc, [SPIntel]));
    case wProcessorLevel of
      3: AddThis(Format(SProcLevl, [SIntel3]));
      4: AddThis(Format(SProcLevl, [SIntel4]));
      5: Addthis(Format(SProcLevl, [SIntel5]));
      6: AddThis(Format(SProcLevl, [SIntel6]));
    else AddThis(Format(SProcLevl, [IntToStr(wProcessorLevel)]));
    end;}
    form1.Memo1.Lines.add(cpuname);
    AddThis(Format(SNumProcs, [dwNumberOfProcessors]));
    MS.dwLength := SizeOf(TMemoryStatus);
    GlobalMemoryStatus(MS);
    AddThis('Ramq' + FormatFloat('#,###" MB"', ((MS.dwTotalPhys div 1024) div 1024)+1));
    AddThis(Format(SMemUse, [MS.dwMemoryLoad]));
  end;
end;

function GetWindowsVersion: string;
var
  VerInfo: TOsversionInfo;
  PlatformId, VersionNumber: string;
  Reg: TRegistry;
begin
  VerInfo.dwOSVersionInfoSize := SizeOf(VerInfo);
  GetVersionEx(VerInfo);
  // Detect platform
  Reg := TRegistry.Create;
  Reg.RootKey := HKEY_LOCAL_MACHINE;
  case VerInfo.dwPlatformId of
    VER_PLATFORM_WIN32s:
      begin
        // Registry (Huh? What registry?)
        PlatformId := 'Windows 3.1';
      end;
    VER_PLATFORM_WIN32_WINDOWS:
      begin
        // Registry
        Reg.OpenKey('\SOFTWARE\Microsoft\Windows\CurrentVersion', False);
        PlatformId    := Reg.ReadString('ProductName');
        VersionNumber := Reg.ReadString('VersionNumber'); 
      end; 
    VER_PLATFORM_WIN32_NT: 
      begin 
        // Registry 
        Reg.OpenKey('\SOFTWARE\Microsoft\Windows NT\CurrentVersion', False); 
        PlatformId    := Reg.ReadString('ProductName'); 
        VersionNumber := Reg.ReadString('CurrentVersion'); 
      end; 
  end; 
  Reg.Free; 
  Result := PlatformId + ' (version ' + VersionNumber + ')'; 
end;

procedure TForm2.FormCreate(Sender: TObject);
Var
 Reg: Tregistry;
 List: TStrings;
 I: Integer;
 aName: String;
begin
 Reg := TRegistry.Create;
 Reg.RootKey := HKEY_CURRENT_USER;
 List := TStringList.Create;
 If Reg.OpenKey(CertifiedGENPluginsLocation, false) then begin
  Reg.GetKeyNames(List);
  For I := 0 to list.count - 1 do begin
   If Reg.OpenKey(PathToOk(CertifiedGENPluginsLocation) + List[I], false) then begin
    aName := Reg.ReadString('');
    Genchklist.Items.Add(aName + ' basic');
    Genchklist.Items.add(aName + ' extended');
    Genchklist.Checked[GenChkList.Items.Count - 2] := True;
   end;
  end;
 end;
 If Reg.OpenKey(CertifiedVISPluginsLocation, false) then begin
  Reg.GetKeyNames(List);
  For I := 0 to list.count - 1 do begin
   If Reg.OpenKey(PathToOk(CertifiedVISPluginsLocation) + List[I], false) then begin
    aName := Reg.ReadString('');
    vischklist.Items.Add(aName);
//    vischklist.Items.add(aName + ' extended');
    vischklist.Checked[visChkList.Items.Count - 1] := True;
   end;
  end;
 end;
 FreeAndNil(List);
 FreeAndNil(Reg);
end;

procedure TForm2.quitClick(Sender: TObject);
begin
 Application.Terminate;
end;

procedure TForm2.nextClick(Sender: TObject);
begin
 Pagecontrol1.SelectNextPage(true);
end;

procedure TForm2.PageControl1Change(Sender: TObject);
begin
 Case PageControl1.ActivePage.Tag of
  1: SetPage0;
  2: Setpage1;
  3: SetPage2;
  4: SetPage3;
  5: SetPage4;
 end;
end;

procedure TForm2.SetPage0;
begin
 back.Visible := false;
 next.Enabled := true;
 quit.Enabled := true;
end;

procedure TForm2.SetPage1;
begin
 back.Visible := true;
 back.Enabled := true;
 next.Enabled := true;
 quit.Enabled := true;
end;

procedure TForm2.SetPage2;
begin
 back.Enabled := false;
 next.Enabled := false;
 quit.Enabled := false;
 application.ProcessMessages;
 // Insert generate code here
 memo1.lines.add('[code]');
 memo1.lines.add('COOLMON 2 - REPORT');
 memo1.lines.add('');
 Memo1.lines.add('');
 If Checkbox1.Checked then begin

 end;
 if Checkbox2.Checked then begin

 end;
 if Checkbox3.Checked then begin

 end;
end;

procedure TForm2.SetPage3;
begin

end;

procedure TForm2.SetPage4;
begin
 Application.Terminate;
end;

end.
