如何使用 Inno Setup 获取系统显示名称?

发布于 2024-10-04 08:06:08 字数 71 浏览 0 评论 0原文

如何获取文件、目录或文件夹的系统显示名称,就像在系统文件浏览器中显示的那样?例如,原始 CD 以某种方式命名,我想做一点复制保护

How can I get system display name of a file, directory, or folder as it would be displayed in a system file browser? For example original CD is named somehow and I want to do little copy protection

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

意犹 2024-10-11 08:06:08

Inno Setup 不提供此类功能。但是,您可以轻松编写自己的 DLL 来调查安装程序的 CD 驱动器的标签。在 Pascal 中,只需执行

function GetCDLabel: string;
var
  VolumeName: PChar;
  dummy: cardinal;
begin
  GetMem(VolumeName, MAX_PATH * sizeof(char));
  try
    if GetVolumeInformation(PChar('D:\'), VolumeName, MAX_PATH + 1, nil, dummy, dummy, nil, 0) then
      result := VolumeName
    else
      RaiseLastOSError; // or result := 'Invalid';
  finally
    FreeMem(VolumeName);
  end;
end;

Inno Setup 即可让您在安装程序中包含 DLL,并在安装过程中调用这些 DLL 中的函数。当然,您的设置必须告诉 DLL 函数其文件名,以便 DLL 函数可以使用正确的驱动器。您不能仅仅假设它是D:\

Inno Setup provides no such functions. However, you can easily write your own DLL that investigates the label of the CD drive of the setup program. In Pascal, just do

function GetCDLabel: string;
var
  VolumeName: PChar;
  dummy: cardinal;
begin
  GetMem(VolumeName, MAX_PATH * sizeof(char));
  try
    if GetVolumeInformation(PChar('D:\'), VolumeName, MAX_PATH + 1, nil, dummy, dummy, nil, 0) then
      result := VolumeName
    else
      RaiseLastOSError; // or result := 'Invalid';
  finally
    FreeMem(VolumeName);
  end;
end;

Inno Setup lets you include DLLs with your setup, and call functions in these DLLs during setup. Of course, your setup must tell the DLL function its filename, so that the DLL function can use the right drive. You cannot just assume it is D:\.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文