Delphi 5在manifest作为资源添加时会导致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'}

Manifest通过调用

编译
C:Program FilesBorlandDelphi5Binbrcc32.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:WindowsWinSxSx86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7600.16385_none_421189da2b7fabfc

从我可以看到的问题是绑定一些Delphi 5与comcomtl32 .dll控件的不兼容。我更新了Delphi VCL到最近的一个。除了迁移到D2007,还有其他解决方案吗?

如果我没记错的话,您需要的不仅仅是清单。您还需要Mike Lischke的主题管理器组件。这段代码最终在Delphi 7中出现。

相关内容

  • 没有找到相关文章

最新更新