Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue using Visual Studio 2010 compiled C++ DLL in Windows 2000

I have a very simple DLL written in unmanaged C++ that I access from my application. I recently switch to Visual Studio 2010, and the DLL went from 55k down to 35k with no code changes, and now it will no longer load in Windows 2000. I didn't change any code or compiler settings. I have my defines setup for 0x0500, which should include Windows 2000 support. Has anyone else run into this, or have any ideas of what I can do?

like image 541
Jon Tackabury Avatar asked Apr 19 '10 00:04

Jon Tackabury


2 Answers

Visual Studio 2010 cannot build binaries that run on Windows 2000. It's actually even worse than that, they won't run on Windows XP RTM or Windows XP Service Pack 1 either. This is because VS2010's C runtime library requires the EncodePointer API which is not available until SP2.

It appears you're stuck building with installing VS2008 if you want to support earlier versions of Windows. You can either move your entire project to Visual Studio 2008 or you can target the vc90 (Visual Studio 2008) toolset from within your Visual Studio 2010 projects. For more details on the latter method, see this anwser to my related question here.

like image 83
Billy ONeal Avatar answered Oct 06 '22 03:10

Billy ONeal


The solution is probably to provide EncodePointer (and DecodePointer, obviously) in a seperate lib, and link that preferentially to KERNEL32.LIB. This is a perfectly supported scenario. In the past, libs like "LIBCTINY" and "UNICOWS" have used this preferential link mechanism to add/replace selected but not all functions from another lib.

like image 22
MSalters Avatar answered Oct 06 '22 03:10

MSalters