English 中文(简体)
通过书记官处编写的文件
原标题:Delphi Detect Word version through Registry

I just added this function which determines which mailmerge method to use. It seems to work on XP and Windows 2000. Is there any reason why it wouldn t work on NT, Vista, 7 and other Windows versions? I m thinking will there be an issue with the registry?

function GetMSOfficeVersion: String;
var Reg: TRegistry;
begin
Result :=  Office Version Not Found ;
// create the registry object
Reg := TRegistry.Create;
try
// set the root key
Reg.RootKey := HKEY_LOCAL_MACHINE;
// check for Office97
if Reg.OpenKey( SOFTWAREMicrosoftOffice8.0 , False) then
begin
Result :=  Microsoft Office97 ;
end;
// check for Office2000
if Reg.OpenKey( SOFTWAREMicrosoftOffice9.0 , False) then
begin
Result :=  Microsoft Office2000 ;
end;
// check for OfficeXP -- not sure if this is correct
// you have to verify the key on a machine with OfficeXP
if Reg.OpenKey( SOFTWAREMicrosoftOffice10.0 , False) then
begin
Result :=  Microsoft OfficeXP(regkey10) ;
end;
// check for 11.0
if Reg.OpenKey( SOFTWAREMicrosoftOffice11.0 , False) then
begin
Result :=  Microsoft OfficeXP(regkey11) ;
end;
// check for 12
if Reg.OpenKey( SOFTWAREMicrosoftOffice12.0 , False) then
begin
Result :=  Microsoft Office2010 ;
end;
finally
// make sure we free the object we created
Reg.Free;
end;
end;
最佳回答

除了确保你以只读方式建立登记册之外,正如Tondrej所建议的那样,你还想确定该法典中的对应版本,因为它是<><>>

在这里,在贵重的法典碎片中,事情发生混乱的那部分是正确的:

10.0 = Office XP
11.0 = Office 2003
12.0 = Office 2007
13.0 - doesn t exist, obvious Microsoft/US numbering standards.
14.0 = Office 2010
问题回答

特权明显不足。 Try using OpenKeyReadOnly,而不是OpenKey

说明为什么不工作”

是的,单个产品可创建<条码>软件处编号0的条目,在具体版本的关键中,应当核对<条码>。 即便如此,也参看。 说 明 浏览器可能制造了“言语”子基,该子key将邮件合并。 如果你真的希望与登记处接洽,则更好地看<代码>。 Word.Application keys in KongEY_CLASSES_ROOT. 除Word.Application.#外。 关键在于<代码>Word.Application 钥匙本身有CurVer

www.un.org/Depts/DGACM/index_french.htm

我将直接尝试创建自动化物体,如果该物体当时无法提供,则该版本将回落到较低版本。 或.。 如:

function IsWord14: Boolean;
begin
  Result := True;
  try
    CreateOleObject( Word.Application.14 );
  except on E:EOleSysError do
    if E.ErrorCode = HRESULT($800401F3) then  // invalid class string
      Result := False
    else
      raise;
  end;
end;




相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签