title: Visual Studio 2015 for Visual Studio 6 Code Compatibility
body: <p>On windows Server 2012 I have installed Visual Studio 2015. Now I have to build Visual Studio C++ 6 based working project in VC++ 2015 but it show various errors and warnings like:</p>
  
  <pre><code>1&gt;------ Build started: Project: Exewrap, Configuration: Debug Win32
  ------ 1&gt;  Pewrap.cpp 1&gt;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include\afx.h(38): warning C4996: 'MBCS_Support_Deprecated_In_MFC': MBCS support in MFC is deprecated and may be removed in a future version of MFC. 1&gt;  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include\afx.h(33): note: see declaration of 'MBCS_Support_Deprecated_In_MFC' 1&gt;  _WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h) 1&gt;c:\muazzam\exewrap\Pe.h(17): warning C4200: nonstandard extension used: zero-sized array in struct/union 1&gt;  c:\muazzam\exewrap\Pe.h(17): note: Cannot generate copy-ctor or copy-assignment operator when UDT contains a zero-sized array 1&gt;Pewrap.cpp(291): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1&gt;  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(205): note: see declaration of 'fopen' 1&gt;Pewrap.cpp(517): error C2065: 'i': undeclared identifier 1&gt;Pewrap.cpp(546): error C2065: 'i': undeclared identifier 1&gt;Pewrap.cpp(551): error C2065: 'i': undeclared identifier 1&gt;Pewrap.cpp(361): warning C4996: 'stricmp': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name:
  _stricmp. See online help for details. 1&gt;  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\string.h(568): note: see declaration of 'stricmp' 1&gt;Pewrap.cpp(362): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use
  _CRT_SECURE_NO_WARNINGS. See online help for details. 1&gt;  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\string.h(346): note: see declaration of 'strncpy' 1&gt;Pewrap.cpp(364): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use
  _CRT_SECURE_NO_WARNINGS. See online help for details. 1&gt;  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\string.h(346): note: see declaration of 'strncpy' 1&gt;Pewrap.cpp(365): warning C4996: 'stricmp': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _stricmp. See online help for details. 1&gt;  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\string.h(568): note: see declaration of 'stricmp' 1&gt;Pewrap.cpp(366): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1&gt;  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\string.h(346): note: see declaration of 'strncpy' 1&gt;Pewrap.cpp(368): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1&gt;  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\string.h(346): note: see declaration of 'strncpy' 1&gt;Pewrap.cpp(369): warning C4996: 'stricmp': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _stricmp. See online help for details. 1&gt;  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\string.h(568): note: see declaration of 'stricmp' 1&gt;Pewrap.cpp(370): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use
  _CRT_SECURE_NO_WARNINGS. See online help for details. 1&gt;  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\string.h(346): note: see declaration of 'strncpy' 1&gt;Pewrap.cpp(372): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use
  _CRT_SECURE_NO_WARNINGS. See online help for details. 1&gt;  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\string.h(346): note: see declaration of 'strncpy' 1&gt;Pewrap.cpp(403): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1&gt;  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\string.h(119): note: see declaration of 'strcpy' 1&gt;Pewrap.cpp(409): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1&gt;  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\string.h(346): note: see declaration of 'strncpy' 1&gt;Pewrap.cpp(410): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1&gt;  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\string.h(346): note: see declaration of 'strncpy' 1&gt;Pewrap.cpp(411): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1&gt;  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\string.h(346): note: see declaration of 'strncpy' 1&gt;Pewrap.cpp(412): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1&gt;  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\string.h(346): note: see declaration of 'strncpy' 1&gt;Pewrap.cpp(480): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1&gt;  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\string.h(119): note: see declaration of 'strcpy' 1&gt;Pewrap.cpp(494): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1&gt;  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\string.h(119): note: see declaration of 'strcpy' 1&gt;Pewrap.cpp(566): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1&gt;  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(205): note: see declaration of 'fopen'
  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  </code></pre>
  
  <p>I didn't see any option in configuration manager for VC++6.</p>
  
  <p>I think <strong>there may be some other configuration options but don't know much about that.</strong> Let me know if any one can help for it.</p>
  
  <p>Further, I have to <strong>re-use code</strong> and build application using VS Studio 2015 cross platform IDE for android and IOS phones </p>
  
  <p>So how to upgrade VC++6 code that should be compatible to latest version of VC++. Meanwhile <a href="https://msdn.microsoft.com/en-us/library/hh266747.aspx" rel="nofollow">this</a> shows:</p>
  
  <blockquote>
    <p>Visual Studio 2012 and Visual Studio 2013 do not support debugging
    applications built with Visual C++ 6; to debug these applications, use
    earlier versions of Visual Studio.</p>
  </blockquote>
  
  <p>Should I upgrade the project from VC++6 -> VC++2010 first and subsequently build projects with upper versions or is there a direct method?</p>
  
  <p><strong>Update:</strong> The code where errors are coming is:</p>
  
  <pre><code>bool Pewrap::Process(PPROTECTIONDETAIL pDetail)
  {
      LPVOID pPosition = NULL;
      LPVOID pImportBegin = NULL;
      DWORD dPosition = 0;
      DWORD dImportRva = 0;
      USERDATA SavedInfo;
      PIMAGE_IMPORT_DESCRIPTOR pImportDesc;
      PIMAGE_IMPORT_BY_NAME pImpByName;
      DWORD * ThunkPtr;
      PSIZEINFO pSize=NULL;
      PROTECTEDINFO ProtInfo;
  
      memset(&amp;SavedInfo,0,sizeof(USERDATA));
      pResBase = 0;
      if(Loaded == true)
      {
          CloseFile();
      }
      if(Loaded == false)
      {
          if(LoadFile(EXTRASIZE)==false)
          {
              return false;
          }
      }
      if(pDetail-&gt;ProtType == PROTECTION_STRONG)
      {
          UseVGCrypt = 1;
          SavedInfo.ProtType = PROTECTION_STRONG;
      }
      else
      {
          UseVGCrypt = 0;
          SavedInfo.ProtType = PROTECTION_MEDIUM;
      }
  
      unsigned char ProdId[PROD_ID_LEN];
      memset(ProdId,0,sizeof(ProdId));
  
      if(GetProtectedInfo(pDetail-&gt;Destination,&amp;ProtInfo)==false)
      {
          GenRsaPrime((DIGIT_T*)ProdId,MOD_SIZE);
          ProdId[0]= ProdId[0] &amp; RSA_MESSAGE_HIGHBIT_MASK;    // needed for rsa algorithm. 
  
      }
      else
      {
          memcpy(ProdId,ProtInfo.prodid,PROD_ID_LEN);
          if(stricmp(pDetail-&gt;Author,"None")==0)
              strncpy(pDetail-&gt;Author,ProtInfo.Author,sizeof(pDetail-&gt;Author));
          else
              strncpy(ProtInfo.Author,pDetail-&gt;Author,sizeof(ProtInfo.Author));
          if(stricmp(pDetail-&gt;Title,"None")==0)
              strncpy(pDetail-&gt;Title,ProtInfo.Title,sizeof(pDetail-&gt;Title));
          else
              strncpy(ProtInfo.Title,pDetail-&gt;Title,sizeof(ProtInfo.Title));
          if(stricmp(pDetail-&gt;PubDate,"None")==0)
              strncpy(pDetail-&gt;PubDate,ProtInfo.PublishDate,sizeof(pDetail-&gt;PubDate));
          else
              strncpy(ProtInfo.PublishDate,pDetail-&gt;PubDate,sizeof(ProtInfo.PublishDate));
      }
  
      SetProtectedInfo(&amp;ProtInfo,pDetail,ProdId);
  
  //  GenRsaPrime((DIGIT_T*)ProdId,MOD_SIZE);
  //  ProdId[0]= ProdId[0] &amp; RSA_MESSAGE_HIGHBIT_MASK;    // needed for rsa algorithm. 
  
  
      memcpy(Key,ProdId,PROD_ID_LEN);
  
      if(pDetail-&gt;TestMode == FALSE)
      {
          RSACTX pubctx,prictx;
          SavedInfo.TestMode = 0;
          GetRsaCtx(&amp;pubctx,(char*)pubcrykey,0);
  
          RsaCrypt(&amp;pubctx,(char*)ProdId,sizeof(ProdId));
          memcpy(SavedInfo.ProductId,ProdId,PROD_ID_LEN);
  
  
      }
      else
      {
          SavedInfo.TestMode = 1;
          memcpy(SavedInfo.ProductId,ProdId,PROD_ID_LEN);
      }
  
      memset(pDetail-&gt;ProdId,0,sizeof(pDetail-&gt;ProdId));
      if(pDetail-&gt;TestMode == TRUE)
      {
          strcpy(pDetail-&gt;ProdId,"None");
      }
      else
      {
          BinToHex((char*)SavedInfo.ProductId,PROD_ID_LEN,pDetail-&gt;ProdId);
      }
      strncpy(SavedInfo.Author,pDetail-&gt;Author,sizeof(SavedInfo.Author)-1);
      strncpy(SavedInfo.Title,pDetail-&gt;Title,sizeof(SavedInfo.Title)-1);
      strncpy(SavedInfo.PublishDate,pDetail-&gt;PubDate,sizeof(SavedInfo.PublishDate)-1);
      strncpy(SavedInfo.RegUrl,pDetail-&gt;RegUrl,sizeof(SavedInfo.RegUrl)-1);
      if(pDetail-&gt;FreeWare == TRUE)   
      {
          SavedInfo.FreeWare = 1;
      }
      else
      {
          SavedInfo.FreeWare = 0;
      }
  
      if(UseVGCrypt)
      {
          VGInit(&amp;ctx,Key,KEYLEN);
      }
  
      PIMAGE_SECTION_HEADER pSecHdr = GetLastSection();
      DWORD align=pImage-&gt;OptionalHeader.SectionAlignment;
  
      if(Length &lt; (pSecHdr-&gt;PointerToRawData+pSecHdr-&gt;SizeOfRawData))
      {
          AfxMessageBox("Actual File Length is less than What is said in Header.\n"
              "The File Might be corrupt.");
          return false;
      }
  
      if(Length &gt; (pSecHdr-&gt;PointerToRawData+pSecHdr-&gt;SizeOfRawData))
      {
          DWORD Size = Length - (pSecHdr-&gt;PointerToRawData+pSecHdr-&gt;SizeOfRawData);
          if(pSecHdr-&gt;Misc.VirtualSize &lt; (pSecHdr-&gt;SizeOfRawData+Size))
          {
              pSecHdr-&gt;Misc.VirtualSize=pSecHdr-&gt;SizeOfRawData+Size;
              pSecHdr-&gt;Misc.VirtualSize= ((pSecHdr-&gt;Misc.VirtualSize / align) * align) + align;
              pImage-&gt;OptionalHeader.SizeOfImage=pSecHdr-&gt;VirtualAddress+pSecHdr-&gt;Misc.VirtualSize;
          }
          pSecHdr-&gt;SizeOfRawData += Size;
      }
  
      pPosition = GetWritePointer();
      if(pPosition == NULL)
          return false;
      dPosition = pSecHdr-&gt;VirtualAddress + pSecHdr-&gt;SizeOfRawData;
  
      memcpy((char*)pPosition,asmStub,sizeof(asmStub));
      pPosition = ADDPTR(LPVOID,pPosition,sizeof(asmStub));
  
      pSize = (PSIZEINFO)pPosition;
  
      pPosition = ADDPTR(LPVOID,pPosition,sizeof(SIZEINFO));
      dPosition += sizeof(asmStub)+sizeof(SIZEINFO);
  
      pImportBegin = pPosition;
  
      IMAGE_DATA_DIRECTORY NullDirectory = { 0,0 };
      SavedInfo.ImportDataDirectory = pImage-&gt;OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT];
      SavedInfo.TlsDataDirectory = pImage-&gt;OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS];
      SavedInfo.BoundImportDirectory = pImage-&gt;OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT];
  
      pImage-&gt;OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS] = NullDirectory;
      pImage-&gt;OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT] = NullDirectory;
  
      pImportDesc =(PIMAGE_IMPORT_DESCRIPTOR) pPosition;
      pImportDesc-&gt;ForwarderChain = 0;
      pImportDesc-&gt;TimeDateStamp = 0;
  
      dPosition+= sizeof(IMAGE_IMPORT_DESCRIPTOR)*2;
      pImportDesc-&gt;Name = dPosition ;
  
      pPosition = ADDPTR(LPVOID,pPosition,(sizeof(IMAGE_IMPORT_DESCRIPTOR) *2));
      strcpy((char*)pPosition,KERNEL32);
      pPosition = ADDPTR(LPVOID,pPosition,sizeof(KERNEL32));
      dPosition+=sizeof(KERNEL32);
  
      pImportDesc-&gt;FirstThunk = dPosition;
      ThunkPtr = (DWORD*) pPosition;
  
      pPosition = ADDPTR(LPVOID,pPosition,(NO_OF_FUNCTIONS +1)* sizeof(IMAGE_THUNK_DATA));
      dPosition += ((NO_OF_FUNCTIONS +1)* sizeof(IMAGE_THUNK_DATA));
  
      for(int i=0;i&lt;NO_OF_FUNCTIONS;i++)
      {
          pImpByName = (PIMAGE_IMPORT_BY_NAME)pPosition;
          pImpByName-&gt;Hint=0;
          strcpy((char*)pImpByName-&gt;Name,FunctionArray[i]);
          *ThunkPtr = dPosition;
          ThunkPtr++;
          pPosition = ADDPTR(LPVOID,pPosition,(sizeof(WORD) + strlen(FunctionArray[i])+1));
          dPosition += (sizeof(WORD) + strlen(FunctionArray[i])+1);
      }
  
      *ThunkPtr = 0;
      pImportDesc++;
      memset(pImportDesc,0,sizeof(IMAGE_IMPORT_DESCRIPTOR));
  
      dImportRva = pSecHdr-&gt;VirtualAddress + pSecHdr-&gt;SizeOfRawData + SUBPTR(DWORD,pImportBegin,GetWritePointer());
  
      DWORD ImportSize = SUBPTR(DWORD,pPosition,pImportBegin);
      pImage-&gt;OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].Size = ImportSize;
      pImage-&gt;OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress = dImportRva;
  
      SavedInfo.OriginalEntryPoint = pImage-&gt;OptionalHeader.AddressOfEntryPoint;
  
      pImage-&gt;OptionalHeader.AddressOfEntryPoint = pSecHdr-&gt;VirtualAddress + pSecHdr-&gt;SizeOfRawData;
  
      PIMAGE_SECTION_HEADER pSecHdrTmp;
      pSecHdrTmp = pImage-&gt;SectionHeader;
      for(i=0;i&lt;pImage-&gt;FileHeader.NumberOfSections;i++)
      {
          pSecHdrTmp-&gt;Characteristics = 0xe0000060;
          pSecHdrTmp++;
      }
  
      DWORD IncreasedSize = SUBPTR(DWORD,pPosition,GetWritePointer());
      DWORD ExtendedMapSize = IncreasedSize;
  
      pSize-&gt;ImportDataSize = ImportSize;
      pSize-&gt;UserDataSize = sizeof(USERDATA);
      pSize-&gt;DllDataSize = sizeof(rawData);
  
      IncreasedSize+= pSize-&gt;UserDataSize;
      IncreasedSize+= pSize-&gt;DllDataSize;
  
      IncreasedSize+= sizeof(PROTECTEDINFO);
  
  
      if(pSecHdr-&gt;Misc.VirtualSize &lt; (pSecHdr-&gt;SizeOfRawData+IncreasedSize))
      {
          pSecHdr-&gt;Misc.VirtualSize=pSecHdr-&gt;SizeOfRawData+IncreasedSize;
          pSecHdr-&gt;Misc.VirtualSize= ((pSecHdr-&gt;Misc.VirtualSize / align) * align) + align;
          pImage-&gt;OptionalHeader.SizeOfImage=pSecHdr-&gt;VirtualAddress+pSecHdr-&gt;Misc.VirtualSize;
      }
  
      pSecHdr-&gt;SizeOfRawData += IncreasedSize;
      PIMAGE_SECTION_HEADER pEncSecHdr = pImage-&gt;SectionHeader;
  
      for(i=0;i&lt;pImage-&gt;FileHeader.NumberOfSections;i++)
      {
          if(CanEncryptSection(pEncSecHdr))
          {
              EncryptSection(pEncSecHdr);
              SavedInfo.EncryptedSections = SavedInfo.EncryptedSections | (0x80000000 &gt;&gt; i);
          }
          pEncSecHdr++;
      }
  
      if(CanEncryptResourceSection())
      {
          EncryptResourceSection();
          SavedInfo.ResourceEncrypted = RESOURCE_IS_INCRYPTED;
      }
  
  //  DWORD temp = MapSize;
  //  MapSize = Length + IncreasedSize;
  //  SaveCopy("out.exe");
  
      FILE * f=fopen((LPCTSTR)pDetail-&gt;Destination,"wb");
      if(f==NULL)
      {
          CString msg;
          msg.Format("Could not open %s for output",pDetail-&gt;Destination);
          AfxMessageBox(msg);
          return false;
      }
      fwrite((char*)pBase,Length+ExtendedMapSize,1,f);
  
      DWORD Temp = UseVGCrypt = 0;
      memcpy(Key,GlobalKey,KEYLEN);
      EncryptData(&amp;SavedInfo,sizeof(USERDATA));
      UseVGCrypt = Temp;
  
      fwrite((char*)&amp;SavedInfo,sizeof(USERDATA),1,f);
      unsigned char * rd = new unsigned char[sizeof(rawData)];
      memcpy(rd,rawData,sizeof(rawData));
      CryptRawData(rd,sizeof(rawData));
      fwrite(rd,sizeof(rawData),1,f);
      delete rd;
  
      fwrite(&amp;ProtInfo,sizeof(ProtInfo),1,f);
  
      fclose(f);
  
      return true;
  
  }   
  </code></pre>