Qt Installer Framework - Reading downloaded package version - c++

Using QtIFW-1.5.0, so far I'm able to generate an online installer for my Qt application on Windows. The installer downloads the appropriate package from my web server and performs some operations defined in the control script installscript.qs, e.g. writing some keys into registry and creating a desktop shortcut with an icon:
installscript.qs:
Component.prototype.createOperations = function()
{
try
{
// call the base create operations function
component.createOperations();
// Add some keys to registry;
var userProfile = installer.environmentVariable("USERPROFILE");
installer.setValue("UserProfile", userProfile);
var reg = installer.environmentVariable("SystemRoot") + "\\System32\\reg.exe";
var key= "HKCU\\Software\\Company\\Product";
component.addOperation("Execute", reg, "ADD", key, "/f");
component.addOperation("Execute", reg, "ADD", key, "/v", "productId", "/t", "REG_BINARY");
// Add a desktop shortcut with icon:
component.addOperation("CreateShortcut",
"#TargetDir#\\MyExecutable.exe",
"#UserProfile#\\Desktop\\MyExecutable.lnk",
"workingDirectory=#TargetDir#",
"iconPath=#TargetDir#\\MyIcon.ico");
}
catch (e)
{
print(e);
}
}
All right, but another key I need to write into registry is the package VERSION NUMBER, defined in the installer configuration file config.xml in tag
<Version></Version>
How can I get this value from installscript.qs ? I read --I'd said more: studied-- the docs component QML Type and installer QML Type and I have not found any reference to version, except:
installer QML type:
boolean versionMatches(string version, string requirement)
which is useless for me, because you have to know the version, which is precisely what I find.
So any help would be appreciated.

You can call
var version = installer.value("ProductVersion");
to get the version specified in the config.xml file.

Related

Modify Default properties on Paraview Properties Panel (5.7.0)

I try to modify the default value of a property in Paraview using a custom Plugin.
When I add a Dicom file in my pipeline, the default representation is set to "Outline" in the property panel, but I want it to be "Volume".
The goal is to interact with existing properties in Paraview
I git clone the paraview repository, and I used CMake to get the .sln file and compile it with Visual Studio. I do the same with example plugin provided by Paraview itself (like the toolbar or property widget to understand how it works), everything works for now.
But when I try to set the data representation to "volume", nothing work (no results, it still uniform.)
What i've tried (from my plugin):
pqApplicationCore* applicationCore = pqApplicationCore::instance();
pqObjectBuilder* objectBuilder = applicationCore->getObjectBuilder();
pqServerManagerModel* serverManagerModel = applicationCore->getServerManagerModel();
if (serverManagerModel->getNumberOfItems<pqServer*>() == 1)
{
// Getting the first (and only) server
pqServer* server = serverManagerModel->getItemAtIndex<pqServer*>(0);
//Creating a reader for dicom files
pqPipelineSource* pipelineSource =
objectBuilder->createReader("sources", "DICOMReader", { file }, server);
// Getting the first view
pqView* v = serverManagerModel->getItemAtIndex<pqView*>(0);
// Setting the data representation to Volume, at least, i try to set it.
pqDataRepresentation* data = objectBuilder->createDataRepresentation(
pipelineSource->getOutputPorts().at(0), v, "UniformGridRepresentation");
// SOLUTION
vtkSMPVRepresentationProxy::SetScalarColoring(data->getProxy(), "DICOMImage", vtkDataObject::POINT);
pqSMAdaptor::setEnumerationProperty(data->getProxy()->GetProperty("Representation"), "Volume");
// wrong
data->setProperty("VolumeRendering", "volume");
data->setVisible(true);
}
CMakeList.txt
set(interfaces)
set(sources
MyToolBar.cxx
MyToolBar.h
MyToolBarActions.cxx
MyToolBarActions.h)
paraview_plugin_add_action_group(…….)
paraview_plugin_add_toolbar(…..)
paraview_add_plugin(pluginName
VERSION "1.0"
UI_INTERFACES ${interfaces}
SOURCES ${sources})
target_link_libraries(cmakePluginName PRIVATE ParaView::ServerManagerRendering)
I expected the "Representation" field to be on "Volume" but still in "Outline"
I also tried to change the "UniformGridRepresentation" to something else, with no results, except weird things and crashes.
Any ideas?
The setProperty you used concern Qt property (this class inherits from QObject) and not ParaView Proxy property.
you should replace this line with the following:
edit: add the SetScalarColoring part
vtkSMPVRepresentationProxy::SetScalarColoring(data->getProxy(), <ArrayName>, vtkDataObject::POINT);
pqSMAdaptor::setEnumerationProperty(data->getProxy()->GetProperty("Representation"), "Volume");
<ArrayName> is the data you want to use for coloration. If not specified, a unique Solid Color is used but it is not available for volume rendering.
vtkDataObject::POINT can also be vtkDataObject::CELL if <ArrayName> is associated to the cells and not to the points.

How to get "INSTALLED" property in Custom Action DLL (MSI/Wix)?

In my custom DLL I need to check if product is being installed or uninstalled, and hence need to get value of "INSTALLED" property (just like in WiX script). Here is what I am doing in C++ DLL:
WCHAR propValue[MAX_PATH];
DWORD propValLen = MAX_PATH;
// MSIHANDLE msiHandle;
MsiGetProperty(msiHandle, L"INSTALLED", propValue, &propValLen);
propValue[propValLen] = 0;
But the outcome is always an empty string (for both installation and uninstallation)! How check if product is being installed or uninstalled?
Property name is case-sensitive, it is "Installed": https://msdn.microsoft.com/en-us/library/windows/desktop/aa369297(v=vs.85).aspx

Bing Map throws exception in 'Windows Runtime Component' project

First of all I want to apologize for the English.
I'am develop windows 8.1 store app. On C++/CX language. My solution contains several projects. One of projects has the 'Windows Runtime Component' type, and perform geocoding and reverse geocoding.
For a geocoding I use 'Bing Maps SDK for Windows 8.1 Store apps'(link).
Here's my algorithm:
void addressByLocation(double latitude, double longitude)
{
ResourceLoader^ loader = ref new ResourceLoader();
String^ credentials = loader->GetString("BingMapCredentials");
Location^ location = ref new Location(latitude, longitude);
ReverseGeocodeRequestOptions^ requestOptions = ref new ReverseGeocodeRequestOptions(location);
Map^ map = ref new Map();
map->Credentials = credentials;
SearchManager^ searchManager = map->SearchManager;
task<LocationDataResponse^> reverseGeocodeTask(searchManager->ReverseGeocodeAsync(requestOptions));
reverseGeocodeTask.then([=](LocationDataResponse^ response)
{
if (!response->HasError)
{
//
}
});
}
I've got the problem in this line:
Map^ map = ref new Map();
It always generates an exception with text:
"Platform::DisconnectedException ^ at memory location 0x0396DF80.
HRESULT:0x80010108 The object invoked has disconnected from its clients.
WinRT information: The object invoked has disconnected from its clients."
But I noticed something weird. If add project to the solution which contains UI(xaml), my code in this project works perfectly fine, without any exceptions.
Can somebody specify an error to me? Or give the explanation for this strange behavior.
There is probably other methods to perform geocoding for windows 8.1 store apps, which I don't know yet.
Thanks.

Read window's registry in QT

I want to list all application which had been installed by reading uninstall registry file from HKEY_CURRENT_USER. But look like it can't be done by using QSettings, for some security reason ( i guess ).
QSettings maya("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall
People suggest to use WinAPI to accomplish this (at least, on Window platform)
Can somebody guide me how to add and use this lib please?
Thank
In order to get the list of all sub items under the "Uninstall" one in the Windows registry you need to use QSettings::childGroups() function, i.e:
QSettings m("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
QSettings::NativeFormat);
QStringList ak = m.childGroups();
This will return the list of all installed applications.
UPDATE:
After getting the list of installed applications one can read the installation details. There are two ways for doing that. For example to read the "UinstallPath" key for "Autodesk Maya 2014" application:
m.beginGroup("Autodesk Maya 2014");
QString path = m.value("UninstallPath").toString();
m.endGroup();
or simply:
QString path = m.value("Autodesk Maya 2014/UninstallPath").toString();

XPCOM CPP code fail to find an existing key in the registry

Here is a simplified example of a code I use in my XPCOM CPP DLL to check if a key exists in the registry.
It checks for the existance of 2 keys: HKLM\SOFTWARE\Microsoft and HKLM\SOFTWARE\Microso both exist with the same permissions, but the first one is found by this code and the second one is not... any idea why?
nsCOMPtr<nsIWindowsRegKey> regKey =
do_CreateInstance("#mozilla.org/windows-registry-key;1");
if (!regKey) {
log("can't create #mozilla.org/windows-registry-key;1");
return -1;
}
NS_NAMED_LITERAL_STRING(key2,
"SOFTWARE\\Microsoft");
if (NS_FAILED(regKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT,
key2, nsIWindowsRegKey::ACCESS_QUERY_VALUE))) {
// FAILED
LOG("regKey:: no such key");
}
NS_NAMED_LITERAL_STRING(key1,
"SOFTWARE\\Microso");
if (NS_FAILED(regKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT,
key1, nsIWindowsRegKey::ACCESS_QUERY_VALUE))) {
// FAILED
LOG("regKey:: no such key");
}
EDIT: To make it clear, I've created a registry key myself, called HKLM\SOFTWARE\Microso and I can access it through regedit.
nsIWindowsRegKey.Open is implemented via RegOpenKeyEx WinAPI function. This function requires existing relative path passed as argument and does not support templates. If there is no exactly same path in the registry, it falls. SOFTWARE\Microsoft is exists in the HKLM root space, HKLM\SOFTWARE\Microso is not.
The issue is most likely that you are viewing the registry with the x64 regedit and then expecting Firefox to have the same view. However, regedit is an x64 application whereas the usual Firefox builds are x86 and run inside the 32-bit subsystem (via WoW64). When an x86 application accesses the HKLM\Software key it gets redirected to HKLM\Software\Wow6432Node. You can run c:\Windows\SysWOW64\regedit.exe instead of c:\Windows\regedit.exe to see the view of the registry that an x86 application gets.
So your XPCOM component is actually trying to access HKLM\Software\Wow6432Node\Microsoft and HKLM\Software\Wow6432Node\Microso - and the former exists while the latter doesn't. If you want to access the "real" registry key instead, you have to pass the WOW64_64 flag in the third parameter of nsIWindowsRegKey.open() (it corresponds to the KEY_WOW64_64KEY flag that can be passed to the RegOpenKeyEx WinAPI function):
NS_NAMED_LITERAL_STRING(key1,
"SOFTWARE\\Microso");
if (NS_FAILED(regKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT, key1,
nsIWindowsRegKey::ACCESS_QUERY_VALUE | nsIWindowsRegKey::WOW64_64))) {
// FAILED
LOG("regKey:: no such key");
}