我有一个应用程序,我必须检查是否已经安装了 .NET FW 3.5。如果已经安装,我想打开一个消息框,要求用户从 Microsoft 网站下载并停止安装。
我找到了以下代码。你能告诉我吗:
a) 我应该从哪里调用这个函数?b) 我是否应该检查是否已安装.NET FW 3.5或更高版本?例如,如果安装了 FW 4.0 - 是否需要安装 3.5?
谢谢
function IsDotNET35Detected(): Boolean;
var
ErrorCode: Integer;
netFrameWorkInstalled : Boolean;
isInstalled: Cardinal;
begin
result := true;
// Check for the .Net 3.5 framework
isInstalled := 0;
netFrameworkInstalled := RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5', 'Install', isInstalled);
if ((netFrameworkInstalled) and (isInstalled <> 1)) then netFrameworkInstalled := false;
if netFrameworkInstalled = false then
begin
if (MsgBox(ExpandConstant('{cm:dotnetmissing}'), mbConfirmation, MB_YESNO) = idYes) then
begin
ShellExec('open',
'http://www.microsoft.com/downloads/details.aspx?FamilyID=333325fd-ae52-4e35-b531-508d977d32a6&DisplayLang=en',
'','',SW_SHOWNORMAL,ewNoWait,ErrorCode);
end;
result := false;
end;
end;