title: Interprocess communication between Inno setups via Pipe cannot create Pipe
body: <p>I would like to separate a huge Inno setup into smaller packages which give their progress and state to the "master" setup. The sub-setups shall be called silent/hidden so that only one window is in front and integrates the progress of all others into one (total)progressbar.
  I've tried to intercommunicate via the Windows pipe system, but even creating a named pipe fails. I've used "\\.\pipe\SetupMsPipe123" and while debugging it showed correctly in the given variable. Even additional escaping like "\\\\.\\pipe\\SetupMsPipe123" failed.
  The return value of the function seems to be an INVALID_HANDLE_VALUE but the Inno variable seems only to hold 4 bytes of the 8 byte handle value.
  Possibly there is something wrong with the type conversion between the variables.</p>
  
  <p>(Updated with the suggestions of TLama)</p>
  
  <pre><code>[Code]   {BOTH}
  type
  #ifdef UNICODE
      #define AW "W"
  #else
      #define AW "A"
  #endif
  #define DefPipeName  "\\.\pipe\SetupMsPipe123"
  var
      mhPipeHandle:   THandle;
      msPipeName  :   string;
  type LPSECURITY_ATTRIBUTES = Cardinal; function CreateNamedPipe(lpName: string; dwOpenMode, dwPipeMode, nMaxInstances, nOutBufferSize, nInBufferSize, nDefaultTimeOut: DWORD; lpSecurityAttributes: LPSECURITY_ATTRIBUTES): THandle;
    external 'CreateNamedPipe{#AW}@kernel32.dll stdcall';
  function WaitNamedPipe(lpNamedPipeName: string; nTimeOut: DWORD): Boolean;
    external 'WaitNamedPipe{#AW}@kernel32 stdcall';
  function ConnectNamedPipe(hNamedPipe: THandle; lpOverlapped: LongWord): Boolean;
    external 'ConnectNamedPipe@kernel32 stdcall';
  function DisconnectNamedPipe(hNamedPipe: THandle): Boolean;
    external 'DisconnectNamedPipe@kernel32 stdcall';
  function CreateFile(lpFileName: string; dwDesiredAccess,dwShareMode: DWORD; lpSecurityAttributes: LPSECURITY_ATTRIBUTES; dwCreationDisposition,dwFlagsAndAttributes: DWORD; hTemplateFile: THandle): LongWord;
    external 'CreateFile{#AW}@kernel32 stdcall';
  function ReadFile(hFile: THandle; lpBuffer: string; nNumberOfBytesToRead: DWORD; var lpNumberOfBytesRead: LongWord; var lpOverlapped: LongWord): Boolean;
    external 'ReadFile@kernel32 stdcall';
  function WriteFile(hFile: THandle; lpBuffer: string; nNumberOfBytesToWrite: DWORD; var lpNumberOfBytesWritten: LongWord; var lpOverlapped: LongWord): Boolean;
    external 'WriteFile@kernel32 stdcall';
  function CloseHandle(hObject: THandle): Boolean;
    external 'CloseHandle@kernel32 stdcall';
  function GetLastError(): DWORD;
    external 'GetLastError@kernel32 stdcall';
  
  [Code]   {MASTER}
  procedure InitializeWizard();
  var 
    lcbProgress: longword;
    lcbFilename: longword;
    bStat:       Boolean;
    lpPipename:  string;
  begin
    msPipeName := ExpandConstant('{#DefPipeName}');
    mhPipeHandle := dllCreateNamedPipe(msPipeName, PIPE_ACCESS_INBOUND, PIPE_TYPE_BYTE or PIPE_NOWAIT, 2, 1024, 1024, 60000, 0);
    if mhPipeHandle &lt;&gt; INVALID_HANDLE_VALUE then begin    
      bStat := dllConnectNamedPipe(mhPipeHandle, 0);
    end;
  end;
  
  procedure CurStepChanged(CurStep: TSetupStep);
  var
    iProgressInner: integer;
    bStat:          Boolean;
    acReadBuffer:   string;
    dwBufLen:       DWORD;
    dwBytesRead:    DWORD;
    dwOverlapped:   DWORD;
  begin
    SetLength(acReadBuffer, 1024);
    if CurStep = ssInstall then begin
      Exec('setupInner.exe', '', '', SW_SHOW, ewNoWait, ResultCode);
      while (iProgressInner&lt;100) do begin
        bStat := ReadFile(mhPipeHandle, acReadBuffer, Length(acReadBuffer), dwBytesRead, dwOverlapped);
        iProgressInner := StrToInt(acReadBuffer);
        WizardForm.Caption:='Progress: ' + IntToStr(iProgressInner);
        WizardForm.Refresh();
        Sleep (1000)     
      end;
    end;
  end;
  
  procedure DeinitializeSetup();
  begin 
    DisconnectNamedPipe(mhPipeHandle);
    CloseHandle(mhPipeHandle);
  end;
  
  [code]  {Slave}
  function InitializeSetup(): Boolean;
  var
    bStat:          Boolean;
    lpOutBuffer:    LongWord;
    nOutBufferSize: DWORD;
    lpBytesRead:    LongWord;
  begin
    msPipeName := ExpandConstant('{#DefPipeName}');
    bStat := WaitNamedPipe(msPipeName, 60000);
    mhPipeHandle := CreateFile(msPipeName, GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
    Result := true;
  end;
  
  procedure CurInstallProgressChanged(CurProgress, MaxProgress: Integer);
  var                   
    iProgress:      integer;
    bStat:          Boolean;
    acWriteBuffer:  String;
    dwBufLen:       DWORD;
    dwWritten:      DWORD;
    dwOverlapped:   DWORD;
    sTemp:          String;
  begin
    sTemp := IntToStr(CurProgress);    
    while Length(sTemp) &lt; 3 do begin
      sTemp := '0' + sTemp;
    end;
    acWriteBuffer := sTemp;
  // Here the exception occurs !!! 
    bStat := WriteFile(mhPipeHandle, acWriteBuffer,    Length(acWriteBuffer), dwWritten, dwOverlapped); 
  end;
  </code></pre>