我找到了另一種方式。也許有人會幫助。這不是我的代碼。
[Code]
var
javaVersion: String;
javaPath: String;
function InitializeSetup(): Boolean;
begin
if RegValueExists(HKLM, 'SOFTWARE\JavaSoft\Java Development Kit', 'CurrentVersion') then
begin
RegQueryStringValue(HKLM, 'SOFTWARE\JavaSoft\Java Development Kit', 'CurrentVersion', javaVersion);
MsgBox('Found Java Development Kit version ' + javaVersion, mbInformation, MB_OK);
if RegValueExists(HKLM, 'SOFTWARE\JavaSoft\Java Development Kit\' + javaVersion, 'JavaHome') then
begin
RegQueryStringValue(HKLM, 'SOFTWARE\JavaSoft\Java Development Kit\' + javaVersion, 'JavaHome', javaPath);
MsgBox('Found Java Development Kit java_home: ' + javaPath, mbInformation, MB_OK);
Result := True;
end
else
begin
MsgBox('Java Path not set for JDK' + javaVersion, mbInformation, MB_OK);
MsgBox('RE-install java', mbInformation, MB_OK);
Result := False;
end
end
else if RegValueExists(HKLM, 'SOFTWARE\JavaSoft\Java Runtime Environment', 'CurrentVersion') then
begin
RegQueryStringValue(HKLM, 'SOFTWARE\JavaSoft\Java Runtime Environment', 'CurrentVersion', javaVersion);
MsgBox('Found Java Runtime Environment version ' + javaVersion, mbInformation, MB_OK);
if RegValueExists(HKLM, 'SOFTWARE\JavaSoft\Java Runtime Environment\' + javaVersion, 'JavaHome') then
begin
RegQueryStringValue(HKLM, 'SOFTWARE\JavaSoft\Java Runtime Environment\' + javaVersion, 'JavaHome', javaPath);
MsgBox('Found Runtime Environment java_home: ' + javaPath, mbInformation, MB_OK);
Result := True;
end
else
begin
MsgBox('Java Path not set for Java Runtime Environment' + javaVersion, mbInformation, MB_OK);
MsgBox('RE-install java', mbInformation, MB_OK);
Result := False;
end
end
else
begin
MsgBox('v1 has not been found on your computer.'#13#13'Please Install it and try again.', MbError, Mb_Ok);
Result := False;
end
end;
function GetJAVAHome(S: String) : String;
begin
Result := javaPath;
end;
Source: "{#MojaAppZrodla}\commapi\comm.jar"; DestDir: "{code:GetJAVAHome}\lib\ext"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "{#MojaAppZrodla}\commapi\win32com.dll"; DestDir: "{code:GetJAVAHome}\bin"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "{#MojaAppZrodla}\commapi\javax.comm.properties"; DestDir: "{code:GetJAVAHome}\lib"; Flags: ignoreversion recursesubdirs createallsubdirs
是否要運行Java代碼以複製文件?你爲什麼不用Inno Setup複製它們?或者你想複製一個JAR文件和一個JRE?請說明你的問題。 – Wosi
最後一行的標記與另一行的標記相同。 – rogal666
因爲我想找到當地的java folde。與「java.lang.System.getProperty(」java.home「)」。例如,某人有某人擁有jre8,另一個人擁有jre7。等等 – rogal666