function ReadMargin(key: string): Real;
  begin
    S := RegwinRegistry.ReadString(key);
    S := Stringreplace(S, ' ', '', [rfReplaceAll]);
    if DecimalSeparator <> '.' then
      S := Stringreplace(S, '.', DecimalSeparator, []);
    if Printoptions.Measure = mMetric then
      result := StrtoFloat(S) * InchToMetric else
      result := StrtoFloat(S);
  end;
begin
  regWinRegistry := TRegistry.Create;
  try
    with regWinRegistry do begin
      RootKey := HKEY_CURRENT_USER;
      if OpenKey('Software/Microsoft/Internet Explorer/PageSetup', False) then
      begin
        PrintOptions.Header := Readstring('header');
        PrintOptions.Footer := ReadString('footer');
        PrintOptions.Margins.left := ReadMargin('margin_left');
        PrintOptions.Margins.right := ReadMargin('margin_right');
        PrintOptions.Margins.top := ReadMargin('margin_top');
        PrintOptions.Margins.bottom := ReadMargin('margin_bottom');
      end;
    end;
  finally
    regWinRegistry.Free;
  end;
end;
    這個函數是在注冊表中去取IE的打印設置,打開注冊表一看,果然沒有'margin_left'這四個項,加上這四個字符串值,并賦上初值0。打開窗口。OK。高興之余也不禁感慨,這個xp的操作系統裝上以后還滅怎么摧殘過,照理這四個鍵不是偶搞掉的,也就說系統裝上就沒有的,到底是microsoft人品有問題還是偶人品有問題已經不重要了,可是偶現在才明白,原來大師的程序也有bug啊,為什么不用StrToFloatDef函數哩?
    今天在公司機器上一看,果然有這四個鍵,每個值為0.75。
    小bug一個,僅作記錄,以供有同樣情形的同志參考。
新聞熱點
疑難解答