3 // Copies a NULL
-terminated
array of characters
to a
string.
4 function ArrayToString(Chars
:array of Char):String;
8 Len
:=GetArrayLength(Chars
);
12 while (i
<Len
) and (Chars
[i
]<>#
0) do begin
13 Result
[i
+1]:=Chars
[i
];
20 // Copies a
string to a NULL
-terminated
array of characters
.
21 function StringToArray(Str
:String):array of Char;
26 SetArrayLength(Result
,Len
+1);
37 // Returns the path
to the common
or user shell folder
as specified
in "Param".
38 function GetShellFolder(Param
:string):string;
40 if IsAdminLoggedOn
then begin
41 Param
:='{common'+Param
+'}';
43 Param
:='{user'+Param
+'}';
45 Result
:=ExpandConstant(Param
);
48 // As IsComponentSelected() is not supported during uninstall
, this work
-around
49 // simply checks the Registry
. This
is unreliable
if the user runs the installer
50 // twice
, the first time selecting the component
, the second deselecting it
.
51 function IsComponentInstalled(Component
:String):Boolean;
53 UninstallKey
,UninstallValue
:String;
58 UninstallKey
:='SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#APP_NAME}_is1';
59 UninstallValue
:='Inno Setup: Selected Components';
61 if RegQueryStringValue(HKEY_LOCAL_MACHINE
,UninstallKey
,UninstallValue
,Value
) then begin
62 Result
:=(Pos(Component
,Value
)>0);
66 // Checks whether the specified directory can be created
and written
to
67 // by creating all intermediate directories
and a temporary
file.
68 function IsDirWritable(DirName
:String):Boolean;
70 AbsoluteDir
,FirstExistingDir
,FirstCreatedDir
,FileName
:String;
74 AbsoluteDir
:=ExpandFileName(DirName
);
76 FirstExistingDir
:=AbsoluteDir
;
77 while not DirExists(FirstExistingDir
) do begin
78 FirstCreatedDir
:=FirstExistingDir
;
79 FirstExistingDir
:=ExtractFileDir(FirstExistingDir
);
81 Log('Line {#__LINE__}: First directory in hierarchy that already exists is "' + FirstExistingDir
+ '".')
83 if Length(FirstCreatedDir
)>0 then begin
84 Log('Line {#__LINE__}: First directory in hierarchy needs to be created is "' + FirstCreatedDir
+ '".')
86 if ForceDirectories(DirName
) then begin
87 FileName
:=GenerateUniqueName(DirName
,'.txt');
88 Log('Line {#__LINE__}: Trying to write to temporary file "' + Filename
+ '".')
90 if SaveStringToFile(FileName
,'This file is writable.',False) then begin
91 if not DeleteFile(FileName
) then begin
101 if not DelTree(FirstCreatedDir
,True,False,True) then begin