我想用inno setup检测用户电脑是否安装了.net framework
2014-04-09 16:32
537 查看
我想用inno setup检测用户电脑是否安装了.net framework,如何通过.net framework的注册表信息来判别,但是它的信息写在了这个HKEY_LOCAL_MACHINE目录下,而访问这个HKEY_LOCAL_MACHINE需要管理员的权限才行。我本机测试(我的操作系统是xp,32位),不管是admin还是user,都可以访问得到里面的信息。我发送到64位的的win7系统的电脑测试,仍然可以访问,而我发送到除我之外的任何一台xp系统或win7(32位)系统的机子,均不能读取注册表里的信息。
请问各位如何解决?
我写的代码如下:
; 脚本由 Inno Setup 脚本向导 生成!
; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!
#define MyAppName "超级无敌大程序"
#define MyAppVersion "1.5"
#define MyAppPublisher "求知科技"
#define IncludeFramework true
#define IsExternal ""
#define MyAppURL "http://www.qiuzhi.com/"
#define MyAppExeName "EasyKao.exe"
[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,点击 工具|在IDE中生成GUID。)
AppId={{D6328262-08DA-47EA-8899-86850CF7D3B1}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputDir=安装
OutputBaseFilename=setup
SetupIconFile=D:\打包测试\Setup.ico
Compression=lzma
SolidCompression=yes
DisableReadyPage=yes
PrivilegesRequired=lowest
[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"
;生成快捷方式
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1
[Files]
Source: "D:\打包测试\x\*"; DestDir: "{app}"; Flags: ignoreversion
;{#IsExternal}; Check: NeedsFramework
Source: "D:\打包测试\x\data\*"; DestDir: "{app}\data"; Flags: ignoreversion
Source: "D:\打包测试\MyProg-x64.exe"; DestDir: "{app}"; DestName: "MyProg.exe"; Check: Is64BitInstallMode
Source: "D:\打包测试\MyProg.exe"; DestDir: "{app}"; Check: not Is64BitInstallMode
;#if IncludeFramework
;Source: "D:\打包测试\x\dotnetfx.exe"; DestDir: "{app}"; Flags: ignoreversion {#IsExternal}; Check: NeedsFramework
;#endif
;Source:"D:\打包测试\you.ico"; DestDir: "{app}";
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon; IconFilename: "{app}\you.ico"
;[Registry]
;Root:HKLM; Subkey: "SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client\Install";Permissions: users-full
;上面的tasks要和【Tasks】的name名称一样,要一一对应
[Run]
;#if IncludeFramework
;Filename: {app}\dotnetfx.exe; Parameters: "/q:a /c:""install /l /q"""; WorkingDir: {tmp}; Flags: skipifdoesntexist; StatusMsg: "Installing .NET Framework if needed"
;#endif
;Filename: {app}\Microsoft.NET\Framework\v4.0.30319\CasPol.exe; Parameters: "-q -machine -remgroup ""{#MyAppName}"""; WorkingDir: {tmp}; Flags: skipifdoesntexist runhidden; StatusMsg: "Setting Program Access Permissions..."
;Filename: {win}\Microsoft.NET\Framework\v4.0.30319\CasPol.exe; Parameters: "-q -machine -addgroup 1.2 -url ""file://{app}/*"" FullTrust -name ""{#MyAppName}"""; WorkingDir: {tmp}; Flags: skipifdoesntexist runhidden; StatusMsg: "Setting Program Access Permissions..."
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent ;
;[UninstallRun]
;Filename: {win}\Microsoft.NET\Framework\v4.0.30319\CasPol.exe; Parameters: "-q -machine -remgroup ""{#MyAppName}"""; Flags: skipifdoesntexist runhidden;
[Code]
function InitializeSetup(): Boolean;
var sVersion: Cardinal;
begin
//Log('InitializeSetup called');
//Result := MsgBox('InitializeSetup:' #13#13 'Setup is initializing. Do you really want to start setup?', mbConfirmation, MB_YESNO) = idYes;
//if Result = False then
// MsgBox('InitializeSetup:' #13#13 'Ok, bye bye.', mbInformation, MB_OK);
if RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client','Install',sVersion) then
if sVersion=1 then
begin
//MsgBox('Your country: ' + IntToStr(sVersion),mbConfirmation, MB_OK);
MsgBox('你的电脑安装了.net4.0', mbInformation,MB_OK);
//Path := ExpandConstant('Setup\dotnetfx.exe');
//Exec(Path, '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
end
else
//检测3.0
begin
if RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5','Install',sVersion) then
if sVersion=1 then
begin
MsgBox('你的电脑安装了.net3.5', mbInformation,MB_OK);
end
else
begin
//检测3.0
if RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0','Install',sVersion) then
if sVersion=1 then
begin
MsgBox('你的电脑安装了.net3.0', mbInformation,MB_OK);
end
else
begin
//检测2.0
if RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0','Install',sVersion) then
if sVersion=1 then
begin
MsgBox('你的电脑安装了.net2.0'+InttoStr(sVersion), mbInformation,MB_OK);
end
else
begin
MsgBox('你的电脑没有安装了.net2.0', mbError,MB_OK);
end
end
end
end
end;
请问各位如何解决?
我写的代码如下:
; 脚本由 Inno Setup 脚本向导 生成!
; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!
#define MyAppName "超级无敌大程序"
#define MyAppVersion "1.5"
#define MyAppPublisher "求知科技"
#define IncludeFramework true
#define IsExternal ""
#define MyAppURL "http://www.qiuzhi.com/"
#define MyAppExeName "EasyKao.exe"
[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,点击 工具|在IDE中生成GUID。)
AppId={{D6328262-08DA-47EA-8899-86850CF7D3B1}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputDir=安装
OutputBaseFilename=setup
SetupIconFile=D:\打包测试\Setup.ico
Compression=lzma
SolidCompression=yes
DisableReadyPage=yes
PrivilegesRequired=lowest
[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"
;生成快捷方式
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1
[Files]
Source: "D:\打包测试\x\*"; DestDir: "{app}"; Flags: ignoreversion
;{#IsExternal}; Check: NeedsFramework
Source: "D:\打包测试\x\data\*"; DestDir: "{app}\data"; Flags: ignoreversion
Source: "D:\打包测试\MyProg-x64.exe"; DestDir: "{app}"; DestName: "MyProg.exe"; Check: Is64BitInstallMode
Source: "D:\打包测试\MyProg.exe"; DestDir: "{app}"; Check: not Is64BitInstallMode
;#if IncludeFramework
;Source: "D:\打包测试\x\dotnetfx.exe"; DestDir: "{app}"; Flags: ignoreversion {#IsExternal}; Check: NeedsFramework
;#endif
;Source:"D:\打包测试\you.ico"; DestDir: "{app}";
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon; IconFilename: "{app}\you.ico"
;[Registry]
;Root:HKLM; Subkey: "SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client\Install";Permissions: users-full
;上面的tasks要和【Tasks】的name名称一样,要一一对应
[Run]
;#if IncludeFramework
;Filename: {app}\dotnetfx.exe; Parameters: "/q:a /c:""install /l /q"""; WorkingDir: {tmp}; Flags: skipifdoesntexist; StatusMsg: "Installing .NET Framework if needed"
;#endif
;Filename: {app}\Microsoft.NET\Framework\v4.0.30319\CasPol.exe; Parameters: "-q -machine -remgroup ""{#MyAppName}"""; WorkingDir: {tmp}; Flags: skipifdoesntexist runhidden; StatusMsg: "Setting Program Access Permissions..."
;Filename: {win}\Microsoft.NET\Framework\v4.0.30319\CasPol.exe; Parameters: "-q -machine -addgroup 1.2 -url ""file://{app}/*"" FullTrust -name ""{#MyAppName}"""; WorkingDir: {tmp}; Flags: skipifdoesntexist runhidden; StatusMsg: "Setting Program Access Permissions..."
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent ;
;[UninstallRun]
;Filename: {win}\Microsoft.NET\Framework\v4.0.30319\CasPol.exe; Parameters: "-q -machine -remgroup ""{#MyAppName}"""; Flags: skipifdoesntexist runhidden;
[Code]
function InitializeSetup(): Boolean;
var sVersion: Cardinal;
begin
//Log('InitializeSetup called');
//Result := MsgBox('InitializeSetup:' #13#13 'Setup is initializing. Do you really want to start setup?', mbConfirmation, MB_YESNO) = idYes;
//if Result = False then
// MsgBox('InitializeSetup:' #13#13 'Ok, bye bye.', mbInformation, MB_OK);
if RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client','Install',sVersion) then
if sVersion=1 then
begin
//MsgBox('Your country: ' + IntToStr(sVersion),mbConfirmation, MB_OK);
MsgBox('你的电脑安装了.net4.0', mbInformation,MB_OK);
//Path := ExpandConstant('Setup\dotnetfx.exe');
//Exec(Path, '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
end
else
//检测3.0
begin
if RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5','Install',sVersion) then
if sVersion=1 then
begin
MsgBox('你的电脑安装了.net3.5', mbInformation,MB_OK);
end
else
begin
//检测3.0
if RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0','Install',sVersion) then
if sVersion=1 then
begin
MsgBox('你的电脑安装了.net3.0', mbInformation,MB_OK);
end
else
begin
//检测2.0
if RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0','Install',sVersion) then
if sVersion=1 then
begin
MsgBox('你的电脑安装了.net2.0'+InttoStr(sVersion), mbInformation,MB_OK);
end
else
begin
MsgBox('你的电脑没有安装了.net2.0', mbError,MB_OK);
end
end
end
end
end;
相关文章推荐
- 如何检测电脑是否安装了.net framework
- 如何检测电脑是否安装了.net framework
- InnoSetup自动检测并安装.Net Framework
- C#winform检测电脑安装的.netframework版本和是否安装了某软件
- JS检测用户是否已安装.net framework
- C#winform检测电脑安装的.netframework版本和是否安装了某软件
- 如何检测电脑是否安装了.net framework
- C#检测目标机器上是否安装Microsoft .NETFramework 1.1平台
- 用dos批处理程序检测是否安装.netframework,并自动安装后运行指定程序(.net自启动光盘的制做)
- C#检测目标机器上是否安装Microsoft .NETFramework 1.1平台
- C#检测目标机器上是否安装Microsoft .NETFramework 1.1平台
- 不显示删除回复显示所有回复显示星级回复显示得分回复 把FrameWork和自己的安装程序(在.net中生成的)集成在一起成为安装包,安装时检测用户是否安装了FrameWork,如果安装了跳过安装FrameWork
- Javascript实现检测客户端是否安装了.NET FrameWork
- C++检测系统是否已经安装了.NET Framework
- 用dos批处理程序检测是否安装.netframework,并自动安装后运行指定程序(.net自启动光盘的制做)
- 【转】C#检测目标机器上是否安装Microsoft .NETFramework平台
- 程序安装时检查是否已经安装.NETFramework [转]
- 如何在没有安装.NET Framework的电脑上运行C#程序
- 如何知道自己的计算机是否安装了.Net Framework 1.1
- 查看是否安装.NET Framework、.NET Framework的版本号、CLR版本号