Category Archives: Platforms and frameworks

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

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…)

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…)

Installing Google Play Services on a Windows 10 with MS VS2015

If Android support is enabled in MS VS2015, it installs Android SDK without Google Play Services and I did not find an option in SDK Manager that installs them. When I started “C:\Program Files (x86)\Android\android-sdk\SDK Manager.exe” with admin privileges, it automatically offered to install some 9 packages:

(more…)

Multiple views with OsgQtQuick

I wrote a sample application using OsgQtQuick that shows the Earth in two views:

with the following QML, that I copied from OsgQtQuick samples:

(more…)

Qt Quick Controls 2 has TableView but without the header yet

QT 5.13 supports SplitView and TableView but without TableHeader yet. Probably TableHeader can be implemented with the overlays. And there is an interesting example of implementation of table header with the source code.

The information provided below is outdated.

Qt Quick Controls 2 does not support TableView and looks like they are not going to support it, some notable missing features from Qt Quick Controls 1 also are Action, SplitView and TreeView, so the following QML code would not work:

TableView {

    TableViewColumn {
        role: "time"
        title: qsTr("date/time:")
        width: parent.width - 30
    }

    TableViewColumn {
        role: "score"
        title: qsTr("result:")
        width: 30
    }

    model: boardModel.list

    ScrollIndicator.vertical: ScrollIndicator { }
}

But there is a solution with ListView, so there can be something like this:

(more…)

What packages QAudioDecoder may require on Ubuntu and CentOS?

If QAudioDecoder does not decode mp3, reporting a format error (GStreamer; Unable to start decoding process), the following package can help:
On Ubuntu:

apt-get install gstreamer0.10-fluendo-mp3

On CentOS:

yum -y install http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
yum install gstreamer{,1}-plugins-ugly

(more…)

QML DropShadow is very slow

QML DropShadow is an interesting effect that acts in a very simple way. It works fine in my application and produces the following result:

QML DropShadow is very slow

The only disadvantage of DropShadow effect is that is slows down my application from 60 FPS to 30 FPS on Android Phone. The following code demonstrates how I use it with StackView:

(more…)

How to start Lines 3D game in auto-play mode.

Lines 3D is a fun logical game with different difficulty levels.  While “Beginner” level is an easy to play relaxing game, the “Professional” and “Expert” levels are good exercises for your brain where you can apply your knowledge in the area of the probability theory. There is also some specific “Baby” level for babies, allowing them to move balls and do not worry about the result.

For IT professionals, there is auto-play mode for testing the application performance and stability. To start Lines 3D game in auto-play mode first install Lines 3D game from Windows Store, start it and select the following game options:

(more…)