Check if VC++ Redistributable 10 is installed through perl script - perl

I am writing a perl script to check if the Visual C++ Redistributable 2010 x64 is installed in the system already.
I came across two ways according to https://blogs.msdn.microsoft.com/astebner/2010/05/05/mailbag-how-to-detect-the-presence-of-the-visual-c-2010-redistributable-package/
To read the registry for the corresponding entry.
or to use MsiQueryProductStateA
Using Win32::TieRegistry is not a possible option with out per setup.
but using use Win32::API is an option
Trying to use MsiQueryProductStateA with Win32::API
use Win32::API;
$function = Win32::API::More->Import(
'msi', 'INSTALLSTATE MsiQueryProductStateA(LPCSTR szProduct)'
);
Supposed to get some valid return value but getting error
Win32::API::parse_prototype: WARNING unknown output parameter type 'INSTALLSTATE' at C:\Program Files\HP\HP BTO Software\nonOV\Perl\a\lib/5.26.2/MSWin32-x64-multi-thread/Win32/API.pm line 600. 4294967294
Could someone please shed some light on how to use/ import the return type as well and how to use this ?
Thanks in advance

Show how to implement in C++ (not in perl) you can refer to.
I installed Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019.
Return value 5 indicate "The product is installed for the current user."
Find the product code in registry like this:
HKEY_CLASSES_ROOT\Installer\Dependencies\Microsoft.VS.VC_RuntimeAdditionalVSU_x86,v14

Related

Verify Microsoft Visual C++ Redistributable (x86) version with PowerShell

I manage an application that requires Microsoft Visual C++ Redistributable (x86) version 14.25.x or higher. The server I'm testing on has version 14.34.31931 and I can find that in PowerShell with:
$Key = Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Dependencies\VC,redist.x86,x86,14.34,bundle'
$Key.Version
I'm wondering, instead of having "VC,redist.x86,x86,14.34,bundle" in that last spot of the Get-ItemProperty, if I can search for something containing "VC,redist.x86" and use that key, regardless of the version? I know if I get that, I can compare the actual version number, but it seems with my current search, I can only search based on already knowing that it's version 14.34.x.

How do I find the source line of a crashing DLL giving the DLL's name and the address of the fault?

The official way to do this appears to be to use WinDbg. That should be able to give me the information I need, very easily. However, I don't have WinDbg, and my attempts to install it have failed for no known reason. So, is there another way to find my bad line of code? Or, is there a way other than using Microsoft's Windows SDK installer to get WinDbg?
My DLL is an unmanaged DLL (no CLR) built using Visual Studio 2012.

Microsoft Visual C++ 8.0 compiler error which occurs when the C++ class API and /or the number of C++ classes in a DLL becomes too large

I was wondering if anyone knew what the number of the Microsoft Visual C++ 8.0 compiler error which occurs when a C++ class API and /or the number of C++ classes in a DLL becomes too large.
Thank you for your help.
My answer to this question is:
That would probably most likely be Microsoft Visual C++ compiler C1002
(http://msdn.microsoft.com/en-US/library/c9e6fs6b%28v=vs.80%29.aspx):
"compiler is out of heap space in pass 2"
Fatal Error C1002
Visual Studio 2005 Other Versions Visual Studio 2012 Visual Studio 2010 Visual Studio 2008 Visual Studio .NET 2003 1 out of 3 rated this helpful - Rate this topic
Error Message
compiler is out of heap space in pass 2
The compiler ran out of dynamic memory space during its second pass, probably due to a program with too many symbols or complex expressions.
To fix by using the following possible solutions
1.Divide the source file into several smaller files.
2.Break expressions into smaller subexpressions.
3.Remove other programs or drivers that consume memory
Please let me know your opinionof this proposed answer.
the solution to this problem i was told this morning is to close the Visual Studio C++ 2008 environment and then restart ii up again.
Shown below is the latest answer I received to the Stack Overflow question:
Microsoft Visual C++ 8.0 compiler error which occurs when the C++ class API and /or the number of C++ classes in a DLL becomes too large
"the compiler's input objects are source files, not dll's. the dll is output of the linker. i never have seen a source file that was too big for compilation. the biggest file i can remember had about 50,000 lines. it probably included header files of same or greater total size.
if your system is low on heap memory it is more likely that the linker would report problems or error because of this. in my opinion it is only a rare chance to happen on a modern system. you also could/should upgrade to newer version of visual studio, for example visual studio 2012 (vc11) is 7 years younger than your compiler. if you were developing on windows xp you should go to vs2008 (vc9) which is more stable than vc8"

Is it possible to create a win64 MEX file that does not require Microsoft Visual C++ Runtime libraries

I am trying to see if you can distribute a MEX file without requiring the end user to install the C++ runtime libraries.
When you use visual 2010 express to create MEXs, Matlab issues this warning :
Warning: Applications/components generated using Microsoft Visual C++
2010 require that the Microsoft Visual Studio 2010 run-time
libraries be available on the computer used for deployment.
To redistribute your applications/components, be sure that the
deployment machine has these run-time libraries.
Is there a compiler that doesn't require to install the run-time libraries on the end machine?
Yes there is: MinGW(-w64) GCC. It only links to the OS library msvcrt.dll (when you link with the -static option), which requires no installation and is part of Windows.
To get Matlab to work with that, you'll need to jump through some hoops. Here is some information. Ignore the Cygwin stuff, and be sure to use a MinGW-w64 toolchain targetting x64 Windows from the link above. Note I haven't personally tested this, but this is your best bet. It's also unsupported by Mathworks, so you are on your own.
As an aside, what's the problem with installing the MSVC++2010 redistributable anyways? There's no effect on licensing, and running MEX code implies having Matlab installed. Installing one more little thing won't be that much trouble IMHO.

CLI tool that lists the DLL files that are mentioned in the Imports section of a Windows PE executable?

I am looking for a CLI tool that will list all of the DLL files referenced in the Import section of a Windows executable file. Back in the day, Windows shipped with a GUI tool called QuickView that provided this information. However, I need a CLI-based application that will provide this information and preferrably a free / open-source application if possible.
IIRC, dumpbin tool from Microsoft could help. It is shipped with Microsoft Visual C++. The details are in MSDN.
Try dumpbin /IMPORTS <pe_file_to_analyze>.
I guess, the tool is not open source, however. But if it is included in Microsoft Visual C++ Express (not sure about that), you can get it for free.
After asking this question and doing some searching, I concluded that the easiest way to get a program like this was to write one. So I did.
The end result was a program named PEImportList (released under the MIT license). It does nothing more than open a PE executable (x86 only at the moment) and read the import data, printing a list of DLL names to the console.
The code will run on any platform and can be found in this single file here:
https://gist.github.com/nathan-osman/5b25da083ad5c6557e89
Simply invoke the program by passing the executable as a parameter. If you want only the DLL names printed, then stick the -l option in front of the executable parameter.