当清单作为资源添加时,Delphi 5会导致EAccessViolation

这是我最近发现的最有趣的问题之一.
我们有一个传统的Delphi 5程序(Rave Reports 4引用阻止升级到D2007).

使用模板生成的版本资源编译程序时,它可以正常工作.当模板生成的清单资源也添加到程序的dpr时,就会出现问题.

Manifest是一个“通用”ASCII文件:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">

  <assemblyIdentity
    name="Name"
    processorArchitecture="x86"
    version="2.0.0.0"
    type="win32"/>

  <description>Desc</description>

  <dependency>
      <dependentAssembly>
          <assemblyIdentity
              type="win32"
              name="Microsoft.Windows.Common-Controls"
              version="6.0.0.0"
              processorArchitecture="x86"
              publicKeyToken="6595b64144ccf1df"
              language="*"
          />
      </dependentAssembly>
  </dependency>

  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
      </requestedPrivileges>
    </security>
  </trustInfo>

  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> 
    <application> 
      <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> 
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
    </application> 
  </compatibility>

</assembly>

在App.dpr中有一个清单资源引用:

{$R 'manifest.res' 'manifest.rc'}

通过调用编译清单:

C:\Program Files\Borland\Delphi5\Bin\brcc32.exe manifest.rc

当程序启动时,会引发异常:

exception class   : EAccessViolation
exception message : Access violation at address 75A1A890 in module 'KERNELBASE.dll'. Read of address 00000001.

主线程的调用堆栈:

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

链接的comctl32.dll:

73f00000 comctl32.dll            6.10.7600.16385    C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7600.16385_none_421189da2b7fabfc

从我所看到的问题是与一些Delphi 5与comctl32.dll控件不兼容的问题.我将Delphi VCL更新到最新版本.除了迁移到D2007之外还有其他解决方案吗?

解决方法

如果我没记错的话,你需要更多只是清单.你还需要 Mike Lischke’s theme manager component.这段代码最终进入了Delphi 7.

相关文章

 从网上看到《Delphi API HOOK完全说明》这篇文章,基本上都...
  从网上看到《Delphi API HOOK完全说明》这篇文章,基本上...
ffmpeg 是一套强大的开源的多媒体库 一般都是用 c/c+&#x...
32位CPU所含有的寄存器有:4个数据寄存器(EAX、EBX、ECX和ED...
1 mov dst, src dst是目的操作数,src是源操作数,指令实现的...