Inno setup 编译器错误-未知类型';t安全描述符';

Inno setup 编译器错误-未知类型';t安全描述符';,inno-setup,Inno Setup,我在Inno安装程序中使用它来创建互斥体,但在编译时收到以下错误:编译器错误-未知类型“TSecurityDescriptor” 我对Inno安装有点陌生,我不确定我需要如何定义此类型,或者我是否应该为此类型包含另一个库。如上面的注释所述:这是Delphi代码。而且它也没那么有用:CreateMutex总是返回一个句柄。如果句柄已经存在,则需要调用GetLastError进行检查 有关更好的Delphi示例,请参阅。这是一个Delphi代码(作为在安装的应用程序中应该执行的操作的示例)。您只需在

我在Inno安装程序中使用它来创建互斥体,但在编译时收到以下错误:编译器错误-未知类型“TSecurityDescriptor”


我对Inno安装有点陌生,我不确定我需要如何定义此类型,或者我是否应该为此类型包含另一个库。

如上面的注释所述:这是Delphi代码。而且它也没那么有用:CreateMutex总是返回一个句柄。如果句柄已经存在,则需要调用GetLastError进行检查


有关更好的Delphi示例,请参阅。

这是一个Delphi代码(作为在安装的应用程序中应该执行的操作的示例)。您只需在Inno设置脚本中指定
AppMutex
指令,如页面底部所示。这就回答了我的问题!谢谢你,特拉玛。我如何判断你的答案是解决方案?(我第一个关于stackoverflow的问题)不客气!好吧,如果我不懒惰的话,我会发布一个你可以标记为接受的答案。但是我现在懒得这么做(对不起:-),所以请随意发布并接受你自己的问题(这是允许的),让其他人回答,或者如果你想删除你的问题,因为这只是对知识库文章的误读,很难说它是否对将来的人有帮助。你请客;-)感谢您的理解,欢迎来到StackOverflow!
procedure CreateMutexes(const MutexName: String);
{ Creates the two mutexes checked for by the installer/uninstaller to see if
  the program is still running.
  One of the mutexes is created in the global name space (which makes it
  possible to access the mutex across user sessions in Windows XP); the
  other is created in the session name space (because versions of Windows NT 
  prior to 4.0 TSE don't have a global name space and don't support the 
  'Global\' prefix). }

const
  SECURITY_DESCRIPTOR_REVISION = 1;  { Win32 constant not defined in Delphi 3 }

var
  SecurityDesc: TSecurityDescriptor;
  SecurityAttr: TSecurityAttributes;

begin
  { By default on Windows NT, created mutexes are accessible only by the user
    running the process. We need our mutexes to be accessible to all users, so
    that the mutex detection can work across user sessions in Windows XP. To
    do this we use a security descriptor with a null DACL. }

  InitializeSecurityDescriptor(@SecurityDesc, SECURITY_DESCRIPTOR_REVISION);
  SetSecurityDescriptorDacl(@SecurityDesc, True, nil, False);
  SecurityAttr.nLength := SizeOf(SecurityAttr);
  SecurityAttr.lpSecurityDescriptor := @SecurityDesc;
  SecurityAttr.bInheritHandle := False;
  CreateMutex(@SecurityAttr, False, PChar(MutexName));
  CreateMutex(@SecurityAttr, False, PChar('Global\' + MutexName));
end;