Building and deploying dll on windows: SxS, manifests and all that jazz

后端 未结 8 852
野性不改
野性不改 2021-02-04 21:47

Since VS 2005, I see that it is not possible to simply build a dll against MS runtime and deploy them together (http://www.ddj.com/windows/184406482). I am deeply confused by ma

8条回答
  •  梦谈多话
    2021-02-04 22:39

    We use a simple include file in all our applications & DLL's, vcmanifest.h, then set all projects to embedded the manifest file.

    vcmanifest.h

    /*----------------------------------------------------------------------------*/
    
    #if _MSC_VER >= 1400
    
    /*----------------------------------------------------------------------------*/
    
    #pragma message ( "Setting up manifest..." )
    
    /*----------------------------------------------------------------------------*/
    
    #ifndef _CRT_ASSEMBLY_VERSION
    #include 
    #endif 
    
    /*----------------------------------------------------------------------------*/
    
    #ifdef WIN64
        #pragma message ( "processorArchitecture=amd64" )
        #define MF_PROCESSORARCHITECTURE "amd64"
    #else
        #pragma message ( "processorArchitecture=x86" )
        #define MF_PROCESSORARCHITECTURE "x86"
    #endif 
    
    /*----------------------------------------------------------------------------*/
    
    #pragma message ( "Microsoft.Windows.Common-Controls=6.0.0.0") 
    #pragma comment ( linker,"/manifestdependency:\"type='win32' " \
                      "name='Microsoft.Windows.Common-Controls' " \
                      "version='6.0.0.0' " \
                      "processorArchitecture='" MF_PROCESSORARCHITECTURE "' " \
                      "publicKeyToken='6595b64144ccf1df'\"" )
    
    /*----------------------------------------------------------------------------*/
    
    #ifdef _DEBUG
        #pragma message ( __LIBRARIES_ASSEMBLY_NAME_PREFIX ".DebugCRT=" _CRT_ASSEMBLY_VERSION ) 
        #pragma comment(linker,"/manifestdependency:\"type='win32' "            \
                "name='" __LIBRARIES_ASSEMBLY_NAME_PREFIX ".DebugCRT' "         \
                "version='" _CRT_ASSEMBLY_VERSION "' "                          \
                "processorArchitecture='" MF_PROCESSORARCHITECTURE "' "         \
                "publicKeyToken='" _VC_ASSEMBLY_PUBLICKEYTOKEN "'\"")
    #else
        #pragma message ( __LIBRARIES_ASSEMBLY_NAME_PREFIX ".CRT=" _CRT_ASSEMBLY_VERSION ) 
        #pragma comment(linker,"/manifestdependency:\"type='win32' "            \
                "name='" __LIBRARIES_ASSEMBLY_NAME_PREFIX ".CRT' "              \
                "version='" _CRT_ASSEMBLY_VERSION "' "                          \
                "processorArchitecture='" MF_PROCESSORARCHITECTURE "' "         \
                "publicKeyToken='" _VC_ASSEMBLY_PUBLICKEYTOKEN "'\"")
    #endif
    
    /*----------------------------------------------------------------------------*/
    
    #ifdef _MFC_ASSEMBLY_VERSION
        #ifdef _DEBUG
            #pragma message ( __LIBRARIES_ASSEMBLY_NAME_PREFIX ".MFC=" _CRT_ASSEMBLY_VERSION ) 
            #pragma comment(linker,"/manifestdependency:\"type='win32' "            \
                    "name='" __LIBRARIES_ASSEMBLY_NAME_PREFIX ".MFC' "              \
                    "version='" _MFC_ASSEMBLY_VERSION "' "                          \
                    "processorArchitecture='" MF_PROCESSORARCHITECTURE "' "         \
                    "publicKeyToken='" _VC_ASSEMBLY_PUBLICKEYTOKEN "'\"")
        #else
            #pragma message ( __LIBRARIES_ASSEMBLY_NAME_PREFIX ".MFC=" _CRT_ASSEMBLY_VERSION ) 
            #pragma comment(linker,"/manifestdependency:\"type='win32' "            \
                    "name='" __LIBRARIES_ASSEMBLY_NAME_PREFIX ".MFC' "              \
                    "version='" _MFC_ASSEMBLY_VERSION "' "                          \
                    "processorArchitecture='" MF_PROCESSORARCHITECTURE "' "         \
                    "publicKeyToken='" _VC_ASSEMBLY_PUBLICKEYTOKEN "'\"")
        #endif
    #endif /* _MFC_ASSEMBLY_VERSION */
    
    /*----------------------------------------------------------------------------*/
    
    #endif /* _MSC_VER */
    
    /*----------------------------------------------------------------------------*/
    

提交回复
热议问题