1

我正在使用 Reprise RLM 许可证管理器研究 Internet 激活。我不知道如何使用 C# 将许可证文件从网络服务器获取到文本文件中(我对 C# 也很陌生)。

RLM 附带了一个 C++ 示例,但我无法翻译它。

我的代码(用于演示)如下所示:

int stat = RLM.rlm_act_request(handle, "http://www.reprisesoftware.com", "rlmactdemo", activationKey, "", "", 1, "", new byte[RLM.RLM_MAX_LINE+1]);
if (stat == 0||stat == 1){
   //Successful connection
   //Read license file and write to local machine
}

rlm_act_request建立并验证连接。建立后,如何访问该文件并将其写入本地文件?

该 if 语句中的任何内容的 C++ 代码如下:

char name[100];
char license[100];
int try;
FILE *f, *fopen();
stat = 1;

for (try=0; try<100; try++)
{
    sprintf(name, "a%d.lic", try);
    f = fopen(name, "r");
    if (f == (FILE *) NULL)
    {
        f = fopen(name, "w");
        if (f)
        {
            fprintf(f, "%s\n", license);
            fclose(f);
            break;
        }
        else
        {
            printf("Error writing license file \"%s\"\n", name);
            stat = -1;
            break;
        }
    }
}

什么是 C# 等价物?

4

1 回答 1

1

嗯,这非常容易。事实证明,传递给 rml_act_request() 的“新字节 []”包含许可证文件的内容。我所要做的就是将其设为局部变量,将其转换为字符串并使用 TextWriter.WriteLine(); 将其写入文件;

我希望这已经记录在某个地方......

于 2009-09-18T17:51:56.997 回答