- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
最初问 here , 但被要求将其作为单独的问题提交。
我在下面的 C 中编写了以下 dll,我在 Inno Setup 安装程序中使用它来提取游戏文件。这是最初使用 16 位安装程序的游戏的替换安装程序,文件是从 CD-ROM 复制的。我希望能够使用 InnoTools InnoCallback显示使用我的 dll 提取的文件名,但由于这是我第一次尝试 C 编码,我不知道该怎么做。此功能的示例可在此处找到:http://freearc.org/InnoSetup.aspx
我希望能够使用外部 dll 中的文件名设置 WizardForm.FilenameLabel.Caption。
我的 Inno Setup 脚本的相关部分:
function VolEx( filename, outputpath: String ): Integer; external 'VolEx@files:volex.dll stdcall';
(DriveLetter 是 CD-ROM 的路径,即“D:\”,因此当前输出为“D:\world\archive.vol”。我的目标输出是“C:\game-路径\世界\存档\file.ext")
procedure VolExtract();
begin
if not DirExists(WizardDirValue() + '\' + Worlds[w]) then
begin
CreateDir(WizardDirValue() + '\' + Worlds[w]);
end;
for n := 0 to 3 do begin
WizardForm.FilenameLabel.Caption := DriveLetter + Worlds[w] + '\' + Reslists[n] + '.vol';
if VolEx(DriveLetter + Worlds[w] + '\' + Reslists[n] + '.vol', WizardDirValue() + '\' + Worlds[w] + '\' + Reslists[n]) <> 0 then
begin
// Handle Fail
MsgBox(CustomMessage('FileErr'), mbInformation, MB_OK);
WizardForm.Close;
end;
VolEx.c(包括来自此处的 blast.c 和 blast.h:https://github.com/madler/zlib/tree/master/contrib/blast)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <sys/stat.h>
#include <time.h>
#include <utime.h>
#include "blast.h"
#define local static
#define VOLID "RESLIST"
struct inbuf {
unsigned long left;
unsigned char *buf;
unsigned size;
FILE *in;
};
struct stat statbuf;
time_t mtime;
time_t voltime;
struct utimbuf new_times;
local unsigned inf(void *how, unsigned char **buf)
{
unsigned len;
struct inbuf *inb = how;
len = inb->size > inb->left ? inb->left : inb->size;
len = fread(inb->buf, 1, len, inb->in);
inb->left -= len;
*buf = inb->buf;
return len;
}
local int outf(void *how, unsigned char *buf, unsigned len)
{
return fwrite(buf, 1, len, (FILE *)how) != len;
}
#define BUFSIZE 16384 /* must fit in unsigned */
local int extract(char *name, unsigned long len, FILE *in, const char *path, time_t prevtime)
{
int err;
FILE *out;
struct inbuf inb;
unsigned char buf[BUFSIZE];
inb.left = len;
inb.buf = buf;
inb.size = BUFSIZE;
inb.in = in;
mkdir(path);
char outPath[strlen(path) + 20];
strcpy(outPath, path);
strcat(outPath, "\\");
strcat(outPath, name);
out = fopen(outPath, "wb");
if (out == NULL)
return 2;
err = blast(inf, &inb, outf, out);
fclose(out);
if (stat(outPath, &statbuf) < 0) {
perror(outPath);
return 1;
}
mtime = statbuf.st_mtime; /* seconds since the epoch */
new_times.actime = statbuf.st_atime; /* keep atime unchanged */
new_times.modtime = prevtime; /* set mtime to current time */
if (utime(outPath, &new_times) < 0) {
perror(outPath);
return 1;
}
return err;
}
int __stdcall __declspec(dllexport) VolEx(const char *filename, const char *outputpath)
{
FILE *in = fopen(filename,"rb");
unsigned long off, next;
int err;
unsigned char head[24];
if (stat(filename, &statbuf) < 0) {
perror(filename);
return 1;
}
voltime = statbuf.st_mtime; /* seconds since the epoch */
if (fread(head, 1, 8, in) != 8 || memcmp(head, VOLID, 8)) {
/* fprintf(stderr, "not the expected .vol format\n"); */
return 1;
}
off = 8;
while ((next = fread(head, 1, 24, in)) == 24) {
off += 24;
next = head[20] + (head[21] << 8) + ((unsigned long)(head[22]) << 16) +
((unsigned long)(head[23]) << 24);
head[20] = 0;
err = extract((char *)head, next - off, in, outputpath, voltime);
if (err) {
/* fprintf(stderr, "extraction error %d on %s\n", err, head); */
return 1;
}
off = next;
}
/* if (next)
fprintf(stderr, "%lu bytes ignored at the end\n", next); */
return 0;
}
最佳答案
查看 InnoTools Callback 中包含的示例脚本.
这非常简单,您只需像这样声明一个过程(同样,假设您使用的是 ANSI Inno——某些类型必须针对 Unicode 版本进行更改):
[Code]
type
TMyCallback = procedure(Filename: PChar);
function WrapMyCallback(Callback: TMyCallback; ParamCount: Integer): LongWord;
external 'WrapCallback@files:innocallback.dll stdcall';
procedure DoSomethingInTheDll(Blah: Integer; Foo: String; ...; Callback: LongWord);
external 'DoSomethingInTheDll@files:mydll.dll stdcall';
procedure MyCallback(Filename: PChar);
begin
// do whatever, eg. update the filename label
end;
// wherever you're about to call your DLL
var Callback : LongWord;
// ...
Callback := WrapMyCallback(@MyCallback, 1); // 1 parameter
// pass the callback to your DLL either via a dedicated function
// or as a parameter of your existing function
DoSomethingInTheDll(blah, foo, ..., Callback);
在 DLL 方面:
typedef void (__stdcall *MyCallback)(const char *filename);
然后您可以在函数参数中声明类型为 MyCallback
的变量,然后调用它们,就好像它们是 native C 函数一样,它将在 Inno 脚本中运行代码。
void __stdcall __declspec(dllexport)
DoSomethingInTheDll(int blah, const char *foo, ..., MyCallback callback)
{
// ...
callback(foo);
}
关于c - 在 Inno Setup 中使用回调显示来自外部解压 dll 的文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18650985/
是否可以获得用于 Inno Setup 安装程序的 Inno Setup 版本号? 我找不到记录的开关来返回其版本号(例如 5.5.6),而且似乎没有暴露给 Inno Setup 脚本的预定义版本常量
我有一个小但令人沮丧的问题。我为可执行文件创建了可能有快捷方式的安装程序,但如果可执行文件不在主文件夹中,可以说 MyProgram\bin\myprogram.exe 安装程序会在主程序文件夹中复制
/VERYSILENT在使用集中式软件将应用程序部署到整个组织时,Inno Setup 提供的选项非常有用,但有一些好处对我来说并不完全清楚。 特别是,在删除需要取消注册并标记为共享对象的 dll/c
我对 Inno Setup 卸载程序有疑问。我有一个 exe 文件,我想执行它来跟踪安装和卸载。该 exe 非常简单,可以向服务器发送消息。 [Files] Source: "Tracker\Loca
我正在使用Inno Setup安装和更新我的python应用程序。 更新时,安装程序不会从以前的安装中删除py文件,这会导致两个问题: 我正在使用插件:如果删除新版本的插件,执行更新的用户仍然可以
我正在使用Inno Setup,并试图关联Windows 7中Program Files (x86)中的程序。我具有以下内容: #define MyAppName "MyView" #define M
我想删除页面底部的标签,我在其中选择了安装组件的目录。标签显示安装应用程序所需的最小磁盘空间。 最佳答案 您想要隐藏 DiskSpaceLabel 控件: [Code] procedure Initi
我们正在将我们的应用程序切换到 .Net4,但我们仍然有使用 Windows XP SP2 的客户。所以我需要在设置中进行额外的检查。 在安装开始时制作一条弹出消息以丢弃 XP SP2 用户非常简单:
这是用于 Inno Setup 的 [Setup] 部分中的 LicenseFile 属性的标准 RTF 文档: 是否可以向此页面添加打印按钮以触发打印许可协议(protocol)? 我看到了一个类似
我有一个 Inno Setup 脚本可以将我的应用程序变成一个 exe。 当我使用 Inno Setup 版本 6 编译代码时,输出文件大小为 110MB(如 Windows Explorer 大
Inno Setup - 我想创建一个类似于屏幕截图的安装程序。 安装程序应在左侧突出显示当前步骤。 如何实现? 最佳答案 @Bill_Stewart 是正确的,普通的 Inno Setup 不提供如
图像作为安装程序背景。如何使用 inno 5.5.9 做到这一点? 最佳答案 我认为这在 Inno Setup 中是不可能的。也许是一些 Inno Setup 克隆。 问题是Inno Setup中的所
这个问题在这里已经有了答案: Inno Setup - Signing fails with "Sign Tool failed with exit code 0x1" (2 个答案) 关闭 3 年
如何获取有关安装程序中包含的文件的信息(最后修改时间戳、文件大小)?通过使用文件的路径,很容易引用磁盘上的文件。但是当文件没有路径时,如何在安装程序中引用它呢? 当安装程序初始化时,我想检查磁盘上是否
Inno Setup 中的单词补全是如何工作的? 如果我在代码中的任何标识符或单词的中间或末尾按 Alt+Right,则没有任何反应。 我找不到任何要安装的扩展,也找不到该主题的 Internet 答
从这里开始:Inno Setup Placing image/control on custom page . 这是做我需要的: CustomPage := CreateCustomPage(wpLi
我的安装程序在组件页面中有一个可视错误。在您开始向下滚动页面之前看起来还不错,但开始看起来一团糟。 我认为问题出在代码中的某个地方,但仅在绝对干净的脚本上重新创建了组件部分,问题仍然存在。尝试更改缩放
如何在 Inno Setup 编译器中为我们的设置提供背景全屏图像。 喜欢下面这张图。 最佳答案 不要那样做。这违反了 Windows 设计指南。 无论如何,如果必须,请使用 WindowVisibl
如何自定义 Inno Setup 安装程序的欢迎页面? 我想创建一个类似于 Skype 安装程序的安装程序,只有 3 个页面: 带有一些选项的自定义欢迎页面 进度页 使用“运行程序”选项完成页面 但是
我已经为我想更新的程序创建了文件。 我希望在安装之前,检查程序是否也在标准目录中,如果不是,则正确的目录可以选择程序所在的位置。 我试过这个: [Files] Source: "C:\Data"; D
我是一名优秀的程序员,十分优秀!