加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

Windows – 如何在Visual Basic 6.0中创建清单文件?

发布时间:2020-12-13 20:09:05 所属栏目:Windows 来源:网络整理
导读:我想在VB 6.0中创建一个清单文件.当我启动应用程序时,操作系统应该要求用户具有管理员权限.我也想知道如何嵌入应用程序? 您实际上并没有在VB中创建清单文件. Windows应用程序清单是格式为XML的标准文本文档.您可以在记事本中创建它,并在应用程序的目录(Your
我想在VB 6.0中创建一个清单文件.当我启动应用程序时,操作系统应该要求用户具有管理员权限.我也想知道如何嵌入应用程序?
您实际上并没有在VB中创建清单文件. Windows应用程序清单是格式为XML的标准文本文档.您可以在记事本中创建它,并在应用程序的目录(YourAppName.exe.manifest)中保存适当的文件名.

Microsoft还提供了更多的信息:Application Manifests.它甚至包含一个示例清单,您可以将其简单地复制并粘贴到一个空白的文本文件中以开始使用.

重要的是,如果您希望应用程序提示用户标高,则将requestedExecutionLevel设置为requireAdministrator,而不是asInvoker.有关使用UAC的清单的具体信息可用here.

所以一个完整的样本可能看起来像这样:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 
  <assemblyIdentity
     version="1.0.0.0"
     processorArchitecture="*"
     name="MyMagicalApplication"
     type="win32"
  /> 
  <description>Sample manifest for your super cool application</description> 

  <!-- Request version 6 of the common controls. -->
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
        type="win32"
        name="Microsoft.Windows.Common-Controls"
        version="6.0.0.0"
        processorArchitecture="*"
        publicKeyToken="6595b64144ccf1df"
        language="*"
      />
    </dependentAssembly>
 </dependency>

  <!-- Identify the application security requirements. -->
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="requireAdministrator"
          uiAccess="false"
        />
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>

将清单嵌入到可执行文件中的传统方式是使用mt.exe utility作为Windows SDK的一部分.

VBAccelerator site还有一些关于在VB 6应用程序中嵌入清单的信息.具体来说,它说:

There are two ways to provide the manifest: the simplest (but least elegant) way is to provide the manifest on disk for an executable. Let’s say your application is called TimeSlot.exe. Then if you save the manifest XML above as

06001

in the same directory as the executable,TimeSlot.exe will automatically get the XP styles. VB5 and VB6 examples are provided. If you rename the .manifest file prior to running the app,you can switch off the XP styles.

A more robust method is to compile the manifest as a resource in your application. To do this,the manifest must appear as resource type RT_MANIFEST (24) with id CREATEPROCESS_MANIFEST_RESOURCE_ID (1). For some bizarre reason,you must also ensure that the resulting XML file is an even multiple of 4 bytes long. So for example,if your file is actually 597 bytes you need to add padding spaces to make up the file size to 600 bytes before compiling. The Resource examples demonstrate how to create this resource file using a resource compiler script (.rc file) and RC.exe.

但是,如果您希望在从VB 6 IDE构建应用程序时自动嵌入清单,那么您将遇到更多困难. VB 6 IDE不支持后期制作步骤,因此您无法在命令行上简单地运行mt.exe来为您执行此操作.有几个在网页上看到的实用程序,声称自动为您自动嵌入清单,但我相信大多数实用程序是只处理请求v6 ComCtl32.dll的旧实用程序.我不知道他们是否容易扩展,以包括UAC权限,但这是值得一提的.这里有一些链接要查看:

> http://vb6zone.blogspot.com/2010/07/make-my-manifest.html
> http://sourceforge.net/projects/ummm/
> http://www.vbforums.com/showthread.php?t=606736
> http://www.vbforums.com/showthread.php?t=430886

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读