If you haven't installed Delphi in a few days, you have installed delphi2007 for Win32. Program . The main part is to detect the variables in the system environment.
1. Operating System Detection
2. Windows Installer version check (minimum configuration 3.1 is required)
3.. NET Framework Version Detection (minimum configuration: 2.0)
4. Office ace oledb driver detection.
Code Share:
1. Operating System detection.
Function getosversion: string;
VaR
Osver: tosversioninfo;
Begin
Result: = 'System version cannot be detected ';
Osver. dwosversioninfosize: = sizeof (osver );
Getversionex (osver );
Case osver. dwmajorversion
6: Result: = 'windows Vista ';
5: Begin
Case osver. dwminorversion
0: Result: = 'windows2000 ';
1: Result: = 'windowsxp ';
2: Result: = 'windows2003 ';
End;
End;
4: Begin
If osver. dwplatformid = ver_platform_win32_nt then
Begin
Result: = 'window nt ';
End
Else
Begin
Case osver. dwminorversion
0: Result: = 'windows95 ';
10: Result: = 'windows98 ';
90: Result: = 'windowsme ';
End;
End;
End;
End;
End;
2. Windows Installer version check
The method is to check the version number of msiexec.exe under system32. If it is 3.1, it will be OK.
Complimentary: method for obtaining the file version.
Function getversion (sfile: string;
Bincludebuild: Boolean): string;
VaR
Dwfvw, dwzero, dwvsf: DWORD;
Major, minor, release, build: DWORD;
Pfvw: pchar;
Pvsf: pvsfixedfileinfo;
S: string;
Begin
Result: = '';
Dwfvw: = getfileversioninfosize (pchar (sfile), dwzero );
If dwfvw <> 0 then
Begin
Getmem (pfvw, dwfvw );
Try
If (getfileversioninfo (pchar (sfile), dwzero, dwfvw, pfvw) then
Begin
If (verqueryvalue (pfvw, '\', pointer (pvsf), dwvsf) then
Begin
If (pvsf ^. dwfileflags and vs_ff_prerel.pdf)> 0) then
Begin
S: = 'beta ';
End
Else begin
S: = '';
End;
Major: = hiword (pvsf ^. dwfileversionms );
Minor: = loword (pvsf ^. dwfileversionms );
Release: = hiword (pvsf ^. dwfileversionls );
Build: = loword (pvsf ^. dwfileversionls );
Result: = format ('% d. % d', [Major, minor, release, build]);
If bincludebuild then
Begin
If release> 0 then
Begin
Result: = format ('% d. % d', [Major, minor, release, build])
End
Else begin
Result: = format ('% d. % d. % d', [Major, minor, build])
End;
End
Else begin
If release> 0 then begin
Result: = format ('% d. % d. % d', [Major, minor, release])
End
Else begin
Result: = format ('% d. % d', [Major, minor])
End;
End;
End;
End;
Finally
Freemem (pfvw );
End;
End;
End;
3.. NET Framework Version Detection.
This is determined based on the registry information and remains to be verified.
Function checknetframework: string;
VaR
Reg: Tregistry;
ValueList: tstringlist;
Begin
Reg: = Tregistry. Create;
ValueList: = tstringlist. Create;
Reg. rootkey: = HKEY_LOCAL_MACHINE;
If not Reg. keyexists ('Software \ Microsoft \. netframework') then
Result: = 'Install. Net framework'
Else
Begin
If Reg. openkey ('Software \ Microsoft \ Net Framework Setup \ NDP ', true) then
Begin
Reg. getkeynames (ValueList );
If ValueList. indexof ('v2. 0.50727 ') <0 then
Result: = 'minimum configuration version: 2.0.50727, current version: '+ stringreplace (ValueList. strings [ValueList. count-1], 'V', '', [rfreplaceall, rfignorecase])
Else
Result: = 'current version: '+ stringreplace (ValueList. Strings [ValueList. Count-1], 'V', '', [rfreplaceall, rfignorecase]);
End;
End;
ValueList. Free;
Reg. Free;
End;
4. Office ace ole db driver judgment
It is also the registry.
Function checkace: Boolean;
VaR
Reg: Tregistry;
Begin
Reg: = Tregistry. Create;
Reg. rootkey: = hkey_classes_root;
If Reg. keyexists ('Microsoft. Ace. oledb.12.0 ') then
Result: = true
Else
Result: = false;
Ispass: = result;
Reg. Free;
End;
Others, such as determining whether IIS is installed or not, and the MDAC version. Let's talk about it later!