Building QT 5.10.1 from sources with VS2017

I am not sure it is a correct way, but I was able to do this:

git clone --recursive https://code.qt.io/qt/qt5.git --branch v5.10.1

and all the submodules were checked out with commit hashes tag v5.10.1 points to:

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
...
Submodule path 'qt3d': checked out '31f424bb81cd2583920d3d521e1e01f01c2d28e2'
...

(more…)

Generating .NET wrappers for COM during build in MS Visual Studio

If in some Visual Studio solution a .NET project references a C++ project that implements a COM server then the following command can be used in Post-Build Event of the C++ project to generate .NET wrapper for COM:

"$(TargetFrameworkSDKToolsDirectory)tlbimp.exe" "$(TargetPath)" /verbose /strictref /asmversion=$(Version) /out:"$(TargetDir)$(TargetName)Lib.dll"

In VS2015 by default this command will generate .NET 4.0 assembly. To generate .NET 2.0 assembly, the following command can be used:

"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\TlbImp.exe" "$(TargetPath)" /verbose /strictref /asmversion=$(Version) /out:"$(TargetDir)$(TargetName)Lib.dll"

I am not sure that changing TargetFrameworkVersion attribute in PropertyGroup Label=”Globals” element of the project file can help here, so it is not clear how to get rid of absolute path.

Also it is impossible to add a reference to a TLB or EXE file to .NET assembly, so using TLB generated by MIDL directly is not an option (MIDL->Output page of C++ project using $(OutDir)$(TargetName).tlb as Type Library name).

How to remove APPX package installed by another user.

There is new option ‘-AllUsers’ in Windows 10 1709 so ‘LinesGame’ APPX package, for example, can be removed for all users with the following command:

Get-AppxPackage -all *lines*
Get-AppxPackage -all *lines* | Remove-AppxPackage -AllUsers

the first line outputs this:

Name                   : 48696GeoGraphX.Lines3D
Publisher              : CN=4596C2AF-8F16-46B2-976A-1D49B97B0C80
Architecture           : X64
ResourceId             :
Version                : 2.0.109.0
PackageFullName        : 48696GeoGraphX.Lines3D_2.0.109.0_x64__rc9z1pmca2qa0
InstallLocation        :
IsFramework            : False
PackageFamilyName      : 48696GeoGraphX.Lines3D_rc9z1pmca2qa0
PublisherId            : rc9z1pmca2qa0
PackageUserInformation : {S-1-5-21-1513020516-1447999005-958985207-1001
                         [S-1-5-21-1513020516-1447999005-958985207-1001]: Installed}
IsResourcePackage      : False
IsBundle               : False
IsDevelopmentMode      : True
IsPartiallyStaged      : False
SignatureKind          : None
Status                 : Ok

Built-in utility for calculating MD5 and SHA1 checksums in Windows 10

To calculate MD5 checksum of a file in Windows 10 open a command prompt and run the following command:

certutil -hashfile <path to the file> MD5

to calculate SHA1 replace MD5 parameter used above with SHA1:

certutil -hashfile <path to the file> SHA1

The possible values of this parameter are: MD2, MD4, MD5, SHA1, SHA256, SHA384, SHA512

ASUS H270M-PLUS Motherboard requires specific network driver for Windows 10.

Windows 10 does not find network driver for ASUS H270M-PLUS motherboard automatically and the driver supplied with the motherboard does not install showing the message “The Realtech network controller was not found. If deep sleep mode is enabled please plug the cable”. But there is some specific Intel(R) Ethernet Connection (2) I219-V driver that works fine:

It is no more possible to mine Ethereum using 3GB graphic card on Windows 10

I mistakenly believed that 3GB of video memory is enough for mining, while EthDcrMiner64.exe does not work with 3GB on Windows 10 and reports the following errors:

Setting DAG epoch #180 for GPU0
Create GPU buffer for GPU0
ETH: 04/08/18-06:19:23 – New job from eth-eu1.nanopool.org:9999
ETH – Total Speed: 0.000 Mh/s, Total Shares: 0, Rejected: 0, Time: 00:00
ETH: GPU0 0.000 Mh/s
CUDA error – cannot allocate big buffer for DAG. Check readme.txt for possible solutions.
ETH: 04/08/18-06:19:25 – New job from eth-eu1.nanopool.org:9999
ETH – Total Speed: 0.000 Mh/s, Total Shares: 0, Rejected: 0, Time: 00:00
ETH: GPU0 0.000 Mh/s
Setting DAG epoch #180 for GPU0
GPU 0, CUDA error 11 – cannot write buffer for DAG

(more…)

Setting up Hyper-V Virtual Machine With Internet Connection

To set up my virtual machines with the internet connection I followed the steps described in Configure Hyper V Virtual Machine With Internet Connection article:

First I created the virtual switch by going to Hyper-V Manager->Virtual Switch Manager:

(more…)

How to run WIX bootstrapper application UI with elevated privileges?

WIX bootstrapper application (BA) can easily determine if it runs as admin with the following code:

using System;
using System.Diagnostics;
using System.Security.Principal;

static bool IsAdmin()
{
    WindowsIdentity id = WindowsIdentity.GetCurrent();
    WindowsPrincipal principal = new WindowsPrincipal(id);
    return principal.IsInRole(WindowsBuiltInRole.Administrator);
}

and if it does not, run a new instance as admin and exit:

static void RunAsAdmin()
{
    ProcessStartInfo proc = new ProcessStartInfo
    {
        UseShellExecute = true,
        WorkingDirectory = Environment.CurrentDirectory,
        FileName = Process.GetCurrentProcess().MainModule.FileName,
        Verb = "runas"
    };

    Process.Start(proc);
}

(more…)

How to check .NET Framework version with WIX installer

WIX has NetFxExtension with NetFx4XXXX packages, so .NET Framework 4.6, for example, can be installed with the single line of code:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:bal="http://schemas.microsoft.com/wix/BalExtension" xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension">
    <Bundle Name="My App">
        ...
        <BootstrapperApplicationRef Id="ManagedBootstrapperApplicationHost">
            <Payload SourceFile="$(var.MySetupUI.TargetPath)"/>
            <Payload SourceFile="$(var.MySetupUI.TargetPath).config"/>
            <Payload SourceFile="$(var.MySetupUI.TargetDir)BootstrapperCore.dll"/>
            <Payload SourceFile="$(var.MySetupUI.TargetDir)BootstrapperCore.xml"/>
            <Payload SourceFile="BootstrapperCore.config"/>

            <Payload SourceFile="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ServiceProcess.dll"/>
            <Payload SourceFile="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Configuration.Install.dll"/>
            <Payload SourceFile="C:\Program Files (x86)\WiX Toolset v3.11\SDK\Microsoft.Deployment.WindowsInstaller.dll"/>
        </BootstrapperApplicationRef>

        <Chain>
            <PackageGroupRef Id='NetFx46Web'/>
            <MsiPackage SourceFile="$(var.MyAppSetup.TargetPath)" Id="InstallationPackageId" Cache="yes" Visible="no"/>
        </Chain>
    </Bundle>
</Wix>

(more…)

A simple WIX installer that runs custom actions on install and uninstall.

Below I provided the source code of WIX installer that shows the license, installation directory and runs custom actions on install and uninstall:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*" Name="My Game" Language="1033" Version="1.0.0.0" Manufacturer="SharLines Corporation" UpgradeCode="...">
        ...    

        <Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" ></Property>
        <WixVariable Id="WixUILicenseRtf" Overridable="yes" Value="License.rtf"/>
        <UIRef Id="WixUI_InstallDir"/>

        <InstallExecuteSequence>
            <Custom Action="InstallService" After="InstallFiles">(NOT Installed) AND (NOT REMOVE)</Custom>
            <Custom Action="UninstallService" After="InstallInitialize">(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
        </InstallExecuteSequence>
        <CustomAction Id="InstallService" Return="check" Impersonate="yes" Execute="deferred" Directory="INSTALLFOLDER" ExeCommand="[INSTALLFOLDER]$(var.MyService.TargetFileName) parameters..."/>
        <CustomAction Id="UninstallService" Return="check" Impersonate="yes" Execute="deferred" Directory="INSTALLFOLDER" ExeCommand="[INSTALLFOLDER]$(var.MyService.TargetFileName) parameters..."/>
    </Product>
    ...
</Wix>

MyService is project referenced by my wixproj in VS2015. If Impersonate=”yes” the command is run as the current user, if “no”, the command is run as “NT AUTHORITY\SYSTEM“. INSTALLFOLDER is defined as follows:

(more…)