title: Delphi 5 causes EAccessViolation when manifest is added as a resource
body: <p>This is one of most interesting problems I have found recently.
  We have a legacy Delphi 5 program (Rave Reports 4 references are preventing from upgrading to D2007).</p>
  
  <p>When program is compiled with our template-generated version resource it works fine. The problem arises when also template-generated manifest resource is added to a program's dpr.</p>
  
  <p>Manifest is a "generic", ASCII file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"&gt;
  
    &lt;assemblyIdentity
      name="Name"
      processorArchitecture="x86"
      version="2.0.0.0"
      type="win32"/&gt;
  
    &lt;description&gt;Desc&lt;/description&gt;
  
    &lt;dependency&gt;
        &lt;dependentAssembly&gt;
            &lt;assemblyIdentity
                type="win32"
                name="Microsoft.Windows.Common-Controls"
                version="6.0.0.0"
                processorArchitecture="x86"
                publicKeyToken="6595b64144ccf1df"
                language="*"
            /&gt;
        &lt;/dependentAssembly&gt;
    &lt;/dependency&gt;
  
    &lt;trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"&gt;
      &lt;security&gt;
        &lt;requestedPrivileges&gt;
          &lt;requestedExecutionLevel level="asInvoker" uiAccess="false"/&gt;
        &lt;/requestedPrivileges&gt;
      &lt;/security&gt;
    &lt;/trustInfo&gt;
  
    &lt;compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"&gt; 
      &lt;application&gt; 
        &lt;supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/&gt; 
        &lt;supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/&gt;
      &lt;/application&gt; 
    &lt;/compatibility&gt;
  
  &lt;/assembly&gt;
  </code></pre>
  
  <p>In App.dpr there is a manifest resource reference:</p>
  
  <pre><code>{$R 'manifest.res' 'manifest.rc'}
  </code></pre>
  
  <p>Manifest is compiled by calling:</p>
  
  <pre><code>C:\Program Files\Borland\Delphi5\Bin\brcc32.exe manifest.rc
  </code></pre>
  
  <p>And when program is started following exception is raised:</p>
  
  <pre><code>exception class   : EAccessViolation
  exception message : Access violation at address 75A1A890 in module 'KERNELBASE.dll'. Read of address 00000001.
  </code></pre>
  
  <p>Call stack for main thread:</p>
  
  <pre><code>main thread ($1144):
  75a1a890 +007 KERNELBASE.dll
  75a1a97c +069 KERNELBASE.dll          WideCharToMultiByte
  73f28764 +048 comctl32.dll            #342
  777741f4 +016 user32.dll              CallWindowProcA
  00092de2 +0ca app.exe        Controls TWinControl.DefaultHandler
  0009336c +01c app.exe        Controls TWinControl.WMNotify
  000c2454 +024 app.exe        ComCtrls TCustomListView.WMNotify
  00090249 +111 app.exe        Controls TControl.WndProc
  00092d0a +1d2 app.exe        Controls TWinControl.WndProc
  000c39ea +072 app.exe        ComCtrls TCustomListView.WndProc
  0009290c +02c app.exe        Controls TWinControl.MainWndProc
  000a5880 +014 app.exe        Forms    StdWndProc
  77757690 +044 user32.dll              SendMessageW
  777741f4 +016 user32.dll              CallWindowProcA
  000c1e6f +0c7 app.exe        ComCtrls TCustomListView.HeaderWndProc
  000a5880 +014 app.exe        Forms    StdWndProc
  7763642b +02b ntdll.dll               KiUserCallbackDispatcher
  77753573 +00a user32.dll              DispatchMessageA
  000ae8c7 +083 app.exe        Forms    TApplication.ProcessMessage
  000ae8fe +00a app.exe        Forms    TApplication.HandleMessage
  000aeb09 +081 app.exe        Forms    TApplication.Run
  00186ecf +077 app.exe        mca      initialization
  75b61192 +010 kernel32.dll            BaseThreadInitThunk
  </code></pre>
  
  <p>Linked comctl32.dll:</p>
  
  <pre><code>73f00000 comctl32.dll            6.10.7600.16385    C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7600.16385_none_421189da2b7fabfc
  </code></pre>
  
  <p>From what I can see the problem is bound with some Delphi 5 incompatibilities with comctl32.dll controls. I updated Delphi VCL to most recent one. Is there any other solution than just migrating to D2007 ?</p>