您好我用Inno Setup(基于Delphi)替换文本文件中的文本有问题.
我的代码:
procedure FileReplaceString(const FileName, searchstring, replacestring: string);
var
fs: TFileStream;
S: string;
begin
fs := TFileStream.Create(FileName, fmOpenread or fmShareDenyNone);
try
SetLength(S, fs.Size);
fs.ReadBuffer(S[1], fs.Size);
finally
fs.Free;
end;
{ the compiler stops here with: unknown identifier 'StringReplace' }
S := StringReplace(S, SearchString, replaceString, [rfReplaceAll, rfIgnoreCase]);
fs := TFileStream.Create(FileName, fmCreate);
try
fs.WriteBuffer(S[1], Length(S));
finally
fs.Free;
end;
end;
Run Code Online (Sandbox Code Playgroud)
我发现我必须使用StringChange(),但我不知道如何在我的代码中使用它.我不太了解Delphi或Inno Setup.我希望你能帮助我.
嗨我正在使用Inno Setup(基于Delphi)来安装我的安装程序.我想要的只是将用户名放在一个字符串中:我的代码:
var
usrname: string;
begin
usrname := GetEnvironmentVariable('USERNAME');
end;
Run Code Online (Sandbox Code Playgroud)
当我尝试编译我的代码时,总是会出现以下错误消息:
未知标识符'GetEnvironmentVariable'
我究竟做错了什么?我是delphi中的新手,所以正确的方法可能是显而易见的.
嘿伙计们,我在for循环中发生了一件非常奇怪的事情.
当我在这里执行此代码时:
#include <stdio.h>
#include <string.h>
char* repeat(char c, int n);
int main(void)
{
char* input;
input = repeat('c', 12);
return 0;
}
char* repeat(char c, int n)
{
char* out;
for (int i = 0; i < 12; ++i) //FIX ITERATION
{
int len = strlen(out);
out[len] = c;
out[len+1] = '\0';
}
printf("%s\n", out);
return out;
}
Run Code Online (Sandbox Code Playgroud)
我得到了预期的输出:
cccccccccccc
Run Code Online (Sandbox Code Playgroud)
但是当我在我的方法中使用传递的int时,像这样:
char* repeat(char c, int n)
{
char* out;
for (int i = 0; i < n; ++i) //VARIABLE …Run Code Online (Sandbox Code Playgroud) 我有编译错误:
Error: incompatible types: Object cannot be converted to String.
Run Code Online (Sandbox Code Playgroud)
在线 String buf = it.next();
public String getMostFrequentColor() {
HashMap<String, Integer> colors = countColors();
int count = 0;
String mfcolour;
Iterator it = colors.keySet().iterator();
while (it.hasNext()) {
String buf = it.next();
if (colors.get(buf) > count) {
count = colors.get(buf);
mfcolour = buf;
}
}
return mfcolour;
}
Run Code Online (Sandbox Code Playgroud)
我不知道为什么会发生这种情况.it.next()在我看来应该返回一个字符串.
inno-setup ×2
pascalscript ×2
c ×1
for-loop ×1
hashmap ×1
iterator ×1
java ×1
loops ×1
pointers ×1
string ×1