Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiler Error - Unknown type 'TSecurityDescriptor'

Tags:

inno-setup

I am using this code in Inno Setup to create a mutex but I am receiving the following error when compiling: Compiler Error - Unknown type 'TSecurityDescriptor'

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;

I am somewhat new to Inno Setup and I'm unsure how I need to define this type or if I am supposed to include another library for this type.

like image 747
Code_Ford Avatar asked Aug 20 '26 01:08

Code_Ford


1 Answers

As written in the comments above: This is Delphi code. And it is not so useful: CreateMutex will always return a handle. You need to call GetLastError to check, if the handle exists already.

See one instance of app per Computer, how? for a better Delphi example.

like image 125
BitBumper Avatar answered Aug 22 '26 22:08

BitBumper