_MSC_VER
is a macro which only exists in LIB or OBJ files for determining linking capabilities, so you can't use dumpbin PEfile /rawdata | find "_MSC_VER"
for compiled EXE or DLL files. In that case you need to check the dependency by running
dumpbin /dependents PEfile
Look for the MSVC*.dll
or VCRUNTIME*.dll
in the dependency list. The number after that is the VC redistributable version
PS C:> dumpbin.exe /dependents C:\qpdf17.dll
[...]
Image has the following dependencies:
ADVAPI32.dll
MSVCP120.dll
MSVCR120.dll
KERNEL32.dll
[...]
PS C:> dumpbin.exe /dependents C:\qpdf26.dll
[...]
Image has the following dependencies:
ADVAPI32.dll
MSVCP140.dll
KERNEL32.dll
VCRUNTIME140.dll
VCRUNTIME140_1.dll
[...]
PS C:>
In the above example MSVCP120 is from MSVC++ 12.0 which means Visual Studio 2013 and _MSC_VER=1800
. Similarly VCRUNTIME140 is from MSVC++ 14.0 which means Visual Studio 2015 and _MSC_VER=1900
. You can check the version and _MSC_VER
values here
Sometimes the /rawdata
option won't even work on LIB or OBJ files. I redirected the output to file and saw that the output is truncated in the middle for some unknown reason. The /dependents
option also doesn't work for them. In that case you need to use another way. If you have GNU tools then you can run either of the below
strings OBJ_or_LIB.file | grep -Po '_MSC_VER=\d+'
grep -aPo '_MSC_VER=\d+' OBJ_or_LIB.file
Or you can also use this PowerShell command
sls -Ca '_MSC_VER=\d+' OBJ_or_LIB.file |% {$_.matches} | select value
or the full command:
Select-String -CaseSensitive '_MSC_VER=\d+' OBJ_or_LIB.file |
ForEach-Object {$_.matches} |
Select-Object value