mt.exeを使用してマニフェストを実行可能ファイルに追加するにはどうすればよいですか?

StackOverflow https://stackoverflow.com/questions/1423492

  •  07-07-2019
  •  | 
  •  

質問

次のコマンドラインを使用して、Windows SDKのmt.exeを使用して、マニフェストを持たない実行可能ファイルに追加しようとしています。

C:\winsdk61>mt.exe -nologo -manifest "r:\shared\hl.exe.manifest" -updateresource:"r:\shared\hl33m.exe;#1"

残念ながら、そうするとこのエラーが出ます:

mt.exe : general error c101008c: Failed to read the manifest from
the resource of file "r:\shared\hl33m.exe". The specified resource
type cannot be found in the image file.

もちろん、リソースがファイル内に見つかりませんでした-ファイルにはマニフェストがありません。そのため、マニフェストを追加します。

マニフェストを実行可能ファイルに追加するにはどうすればよいですか?これは単純ではないでしょうか?

役に立ちましたか?

解決

/ updateresource:の代わりに / outputresource を使用する必要があります。

正しいコマンドラインは次のとおりです。

mt.exe -nologo -manifest "r:\shared\hl.exe.manifest" -outputresource:"r:\shared\hl33m.exe;#1"

他のヒント

これはVS 2005で私のために働いた:

  1. 実行可能ファイル名に拡張子マニフェストを付けたテキストファイルを作成し、コードファイルと同じパスにあることを確認します。つまり、Form1.csなど。たとえば、アプリ名がUACTester.exeの場合、マニフェストファイルの名前はUACTester.exe.manifestである必要があります。
  2. マニフェストの内容が適切であることを確認します。私はこれを使用します:
    <?xml version="1.0" encoding="utf-8"?>
    <asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"
     xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" 
     xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
        <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
            <security>
                <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
                    <requestedExecutionLevel level="requireAdministrator" 
                     uiAccess="false" />
                </requestedPrivileges>
                <applicationRequestMinimum>
                    <defaultAssemblyRequest permissionSetReference="Custom" />
                    <PermissionSet class="System.Security.PermissionSet" 
                     version="1" ID="Custom" SameSite="site" />
                </applicationRequestMinimum>
            </security>
        </trustInfo>
        <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
            <application>
            </application>
        </compatibility>
    </asmv1:assembly>
  1. 実行可能プロジェクトで、次のビルド後イベントを追加します。

    &quot; $(DevEnvDir).. \ Tools \ Bin \ mt.exe&quot; -nologo -manifest&quot; $(TargetPath).manifest&quot; -outputresource:&quot; $(TargetPath)&quot;

これが役立つことを願っています。がんばろう! -Matt Esterak

このように使用して、EXEファイル内にマニフェストを埋め込むこともできます。

mt.exe -nologo -manifest&quot; r:\ shared \ hl.exe.manifest&quot; -outputresource:&quot; r:\ shared \ hl33m.exe; 1&quot;

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top