zoukankan      html  css  js  c++  java
  • 指向输入c# 工程加入 win32 资源文件

    本文是一篇关于指向输入的子帖

    
    

        这类情事就是一个字烦人,蛋疼,特殊蛋疼。 搞了我一天。

        方法有几种,都特殊烦,一个是 build event , 一个是 msbuild

        今天说 build event

        1.在 Build Events 中 , Pre-build 

        输入:

    copy  $(ProjectDir)Time/norlib.Time.Holidays.xml  "$(TargetDir)norlib.Time.Holidays.xml"
    
    set VCInclude=C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include
    set SDKInclude=C:\Program Files (x86)\Windows Kits\8.0\Include\um
    set SDKShared=C:\Program Files (x86)\Windows Kits\8.0\Include\shared
    echo $(IntermediateOutputPath)
    
    set RCDIR=
    IF EXIST "C:\Program Files (x86)\Windows Kits\8.0\bin\x86\rc.exe" (set RCDIR="C:\Program Files (x86)\Windows Kits\8.0\bin\x86\rc.exe")
    
    echo  (%RCDIR%  /i "%VCInclude%"  /i "%SDKInclude%" /r /fo "$(IntermediateOutputPath)\res1.res" "$(ProjectDir)Controls\OpenFileOrFolderDialog\res1.rc")
    
    if not defined RCDIR ( echo "Error! Unable to find rc.exe.")  else  (%RCDIR%  /i "%VCInclude%"  /i "%SDKInclude%" /i "%SDKShared%" /r /fo "$(ProjectDir)res1.res" "$(ProjectDir)Controls\OpenFileOrFolderDialog\res1.rc")
    
    if not defined RCDIR (Exit 1)

        主要是从第二行开始看

        首先要注意 c# 面下很多宏是失效的, 比如 $(VCInstallDir) , 还有写宏和 vc 是指向不一样的录目,比如他妈的: $(FrameworkSdkDir)

        这个宏 $(FrameworkSdkDir)  在vc下 指向: C:\program files(x86)\windows kits\8.0\  在里面bin\x86 我们可以找到rc.exe

        但是在 c# 下指向:C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\

        间瞬晕死, google了半天发明个子帖:

        http://go4answers.webhost4life.com/Example/get-winsdk-configuration-tool-work-41266.aspx

        他这么说的:

        每日一道理
    人生好似一条河,既有波澜壮阔,汹涌澎湃,也有清风徐来,水波不兴;人生好似一首歌,既有欢乐的音符,也有悲壮的旋律;人生好似一条船,既有一帆风顺时,也有急流险滩处。愿我们都能勇于经受暴风雨的洗礼,接受生活的挑战和考验!
    After some investigation and reflecting using Redgate Reflector, I found that the variable $(FrameworkSDKDir) will always resolve to the 6.0a installation if that SDK is installed and the target framework is 3.5. This is due to a possible bug in the .NET Type Microsoft.Build.Shared.FrameworkLocationHelper, in assembly Microsoft.Build.Utilities.v3.5, Version=3.5.0.0 that shipped with .NET Framework 3.5. The problem I see is in the property PathToDotNetFrameworkSdkV35 in this class. It first reads the registry value for SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0A\InstallationFolder, while I believe it should actually first read SOFTWARE\Microsoft\Microsoft SDKs\Windows\CurrentInstallFolder. 
    
    I worked around this problem by hacking the key SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0A\InstallationFolder to point to 6.1. This enables me to use rc.exe from SDK 6.1, while it might affect other products that expects to retrieve the 6.0a installation folder from the registry.
    
    I have the following questions regarding the issues described above:
    
    
    Why would rc.exe install  to different locations on two otherwise seemingly equivalent machines? 
    Is the code that I refered to in Microsoft.Build.Shared.FrameworkLocationHelper affected by a bug? and if so
    Is there a work around / fix other that the method that I described?

        反正要解决也挺麻烦的,后来如你所见我就在 build events 里面创建了一个 %Macro%

        比如:

        

    set VCInclude=C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include

        这里要注意了,你不能写 VCInclude =....... 这样Macro变成了 %VCInclude % .........还有就是不需要双引号。

        

        这样编译成功后, 就有了一个 res 文件,我们千辛万苦就是为了得到这个res文件

        然后 c# Project Property -> Application -> Resources -> Resource file (radio button):  输入res文件的绝对路径

        这样就能加入了win32资源文件了

        

        里面挺好玩的。

        

        参考:

        http://stackoverflow.com/questions/8057080/how-to-embed-a-resource-in-a-net-pe-executable

        http://blogs.msdn.com/b/astebner/archive/2006/02/28/541036.aspx

        以后还是要上MSBUILD

    文章结束给大家分享下程序员的一些笑话语录: 自从有了Photoshop,我再也不相信照片了!(没有Photoshop的年代,胶片照片年代做假的也不少,那时候都相信假的!)

  • 相关阅读:
    如何产生 XPO 的WCF服务中间层
    法国达索公司 -- 全球出色的产品设计和体验解决方案商
    DevExpress Ribbon布局多文档界面—XtraTabControl动态增加Tab和关闭选项卡方法 (转)
    Axure 案例及基础部件
    低代码平台
    体检结果(2018年10月,胃肠镜)
    功能性肠道疾病用药一览表
    spartan 6 asynchronous reset and set
    理想
    matlab GUI 初学
  • 原文地址:https://www.cnblogs.com/xinyuyuanm/p/3038750.html
Copyright © 2011-2022 走看看