Skip to content
This repository was archived by the owner on Nov 29, 2024. It is now read-only.

Commit 33a72ac

Browse files
committed
MsiUseFeature utility added
(closes #3)
1 parent d430b63 commit 33a72ac

12 files changed

+310
-15
lines changed

CredWrite/StdAfx.h

-15
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,3 @@
3232
#include <tchar.h>
3333

3434
#include <memory>
35-
36-
//#include "../include/Version.h"
37-
//
38-
//#include "../EAPMethods/include/EAP.h"
39-
//#include "../EAPMethods/include/PAP.h"
40-
//
41-
//#include <WinStd/Base64.h>
42-
//#include <WinStd/Cred.h>
43-
//#include <WinStd/Crypt.h>
44-
//#include <WinStd/Win.h>
45-
//
46-
//#include <tchar.h>
47-
//#include <Windows.h>
48-
//
49-
//#include <memory>

Makefile

724 Bytes
Binary file not shown.

MsiUseFeature/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/temp
2+
/*.user

MsiUseFeature/Main.cpp

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
Copyright 2015-2016 Amebis
3+
Copyright 2016 GÉANT
4+
5+
This file is part of GÉANTLink.
6+
7+
GÉANTLink is free software: you can redistribute it and/or modify it
8+
under the terms of the GNU General Public License as published by
9+
the Free Software Foundation, either version 3 of the License, or
10+
(at your option) any later version.
11+
12+
GÉANTLink is distributed in the hope that it will be useful, but
13+
WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License
18+
along with GÉANTLink. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
#include "StdAfx.h"
22+
23+
#pragma comment(lib, "Msi.lib")
24+
25+
using namespace std;
26+
using namespace winstd;
27+
28+
29+
static int MsiUseFeature()
30+
{
31+
int nArgs;
32+
unique_ptr<LPWSTR[], LocalFree_delete<LPWSTR[]> > pwcArglist(CommandLineToArgvW(GetCommandLineW(), &nArgs));
33+
if (pwcArglist == NULL) {
34+
OutputDebugStr(_T("CommandLineToArgvW failed (error %u).\n"), GetLastError());
35+
return 1;
36+
}
37+
38+
if (nArgs < 2) {
39+
OutputDebugStr(_T("Not enough parameters.\n"));
40+
return -1;
41+
}
42+
43+
// Query the feature state.
44+
if (MsiQueryFeatureStateW(_L(PRODUCT_VERSION_GUID), pwcArglist[1]) == INSTALLSTATE_UNKNOWN) {
45+
OutputDebugStr(_T("The product is not installed or feature state is unknown.\n"));
46+
return 1;
47+
}
48+
49+
// Perform the Microsoft Installer's feature completeness check.
50+
if (MsiUseFeatureW(_L(PRODUCT_VERSION_GUID), pwcArglist[1]) != INSTALLSTATE_LOCAL) {
51+
OutputDebugStr(_T("The feature is not installed locally.\n"));
52+
return 2;
53+
}
54+
55+
return 0;
56+
}
57+
58+
59+
int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow)
60+
{
61+
UNREFERENCED_PARAMETER(hInstance);
62+
UNREFERENCED_PARAMETER(hPrevInstance);
63+
UNREFERENCED_PARAMETER(lpCmdLine);
64+
UNREFERENCED_PARAMETER(nCmdShow);
65+
66+
int res = MsiUseFeature();
67+
assert(!_CrtDumpMemoryLeaks());
68+
return res;
69+
}

MsiUseFeature/MsiUseFeature.props

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ImportGroup Label="PropertySheets" />
4+
<PropertyGroup Label="UserMacros" />
5+
<PropertyGroup>
6+
<OutDir>..\output\$(Platform).$(Configuration)\</OutDir>
7+
</PropertyGroup>
8+
<ItemDefinitionGroup>
9+
<ClCompile>
10+
<AdditionalIncludeDirectories>..\lib\WinStd\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
11+
</ClCompile>
12+
</ItemDefinitionGroup>
13+
<ItemGroup />
14+
</Project>

MsiUseFeature/MsiUseFeature.rc

4.76 KB
Binary file not shown.

MsiUseFeature/MsiUseFeature.vcxproj

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Debug|x64">
9+
<Configuration>Debug</Configuration>
10+
<Platform>x64</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Release|Win32">
13+
<Configuration>Release</Configuration>
14+
<Platform>Win32</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<ProjectGuid>{679D03C5-CD70-4FFA-93F8-A4AB3637509B}</ProjectGuid>
23+
<Keyword>Win32Proj</Keyword>
24+
<RootNamespace>MsiUseFeature</RootNamespace>
25+
</PropertyGroup>
26+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
27+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
28+
<ConfigurationType>Application</ConfigurationType>
29+
<UseDebugLibraries>true</UseDebugLibraries>
30+
<CharacterSet>Unicode</CharacterSet>
31+
</PropertyGroup>
32+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
33+
<ConfigurationType>Application</ConfigurationType>
34+
<UseDebugLibraries>true</UseDebugLibraries>
35+
<CharacterSet>Unicode</CharacterSet>
36+
</PropertyGroup>
37+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
38+
<ConfigurationType>Application</ConfigurationType>
39+
<UseDebugLibraries>false</UseDebugLibraries>
40+
<WholeProgramOptimization>true</WholeProgramOptimization>
41+
<CharacterSet>Unicode</CharacterSet>
42+
</PropertyGroup>
43+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
44+
<ConfigurationType>Application</ConfigurationType>
45+
<UseDebugLibraries>false</UseDebugLibraries>
46+
<WholeProgramOptimization>true</WholeProgramOptimization>
47+
<CharacterSet>Unicode</CharacterSet>
48+
</PropertyGroup>
49+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
50+
<ImportGroup Label="ExtensionSettings">
51+
</ImportGroup>
52+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
53+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
54+
<Import Project="..\include\Win32.props" />
55+
<Import Project="..\include\Debug.props" />
56+
<Import Project="MsiUseFeature.props" />
57+
</ImportGroup>
58+
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
59+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
60+
<Import Project="..\include\x64.props" />
61+
<Import Project="..\include\Debug.props" />
62+
<Import Project="MsiUseFeature.props" />
63+
</ImportGroup>
64+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
65+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
66+
<Import Project="..\include\Win32.props" />
67+
<Import Project="..\include\Release.props" />
68+
<Import Project="MsiUseFeature.props" />
69+
</ImportGroup>
70+
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
71+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
72+
<Import Project="..\include\x64.props" />
73+
<Import Project="..\include\Release.props" />
74+
<Import Project="MsiUseFeature.props" />
75+
</ImportGroup>
76+
<PropertyGroup Label="UserMacros" />
77+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
78+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
79+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
80+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
81+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
82+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
83+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
84+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
85+
<ItemGroup>
86+
<ClInclude Include="StdAfx.h" />
87+
</ItemGroup>
88+
<ItemGroup>
89+
<ClCompile Include="Main.cpp" />
90+
<ClCompile Include="StdAfx.cpp">
91+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
92+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
93+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
94+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
95+
</ClCompile>
96+
</ItemGroup>
97+
<ItemGroup>
98+
<None Include="README.md" />
99+
</ItemGroup>
100+
<ItemGroup>
101+
<ResourceCompile Include="MsiUseFeature.rc" />
102+
</ItemGroup>
103+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
104+
<ImportGroup Label="ExtensionTargets">
105+
</ImportGroup>
106+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Header Files">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Resource Files">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClInclude Include="StdAfx.h">
19+
<Filter>Header Files</Filter>
20+
</ClInclude>
21+
</ItemGroup>
22+
<ItemGroup>
23+
<ClCompile Include="StdAfx.cpp">
24+
<Filter>Source Files</Filter>
25+
</ClCompile>
26+
<ClCompile Include="Main.cpp">
27+
<Filter>Source Files</Filter>
28+
</ClCompile>
29+
</ItemGroup>
30+
<ItemGroup>
31+
<None Include="README.md" />
32+
</ItemGroup>
33+
<ItemGroup>
34+
<ResourceCompile Include="MsiUseFeature.rc">
35+
<Filter>Resource Files</Filter>
36+
</ResourceCompile>
37+
</ItemGroup>
38+
</Project>

MsiUseFeature/README.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#MsiUseFeature
2+
Checks the installation state of the given feature of GÉANTLink product
3+
4+
##Usage
5+
```
6+
MsiUseFeature <feature name>
7+
```
8+
9+
- `feature name` - The name of the feature to check (i.e. "featEAPTTLS"; see Feature table of product MSI file)
10+
11+
Note: The MSI product code changes on every release. Therefore, `MsiUseFeature` utility with identical version should be used.
12+
13+
Return codes:
14+
- -1 = Invalid parameters
15+
- 0 = Success
16+
- 1 = The product is not installed or feature state is unknown
17+
- 2 = The feature is not installed locally

MsiUseFeature/StdAfx.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
Copyright 2015-2016 Amebis
3+
Copyright 2016 GÉANT
4+
5+
This file is part of GÉANTLink.
6+
7+
GÉANTLink is free software: you can redistribute it and/or modify it
8+
under the terms of the GNU General Public License as published by
9+
the Free Software Foundation, either version 3 of the License, or
10+
(at your option) any later version.
11+
12+
GÉANTLink is distributed in the hope that it will be useful, but
13+
WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License
18+
along with GÉANTLink. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
#include "StdAfx.h"

MsiUseFeature/StdAfx.h

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
Copyright 2015-2016 Amebis
3+
Copyright 2016 GÉANT
4+
5+
This file is part of GÉANTLink.
6+
7+
GÉANTLink is free software: you can redistribute it and/or modify it
8+
under the terms of the GNU General Public License as published by
9+
the Free Software Foundation, either version 3 of the License, or
10+
(at your option) any later version.
11+
12+
GÉANTLink is distributed in the hope that it will be useful, but
13+
WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License
18+
along with GÉANTLink. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
#pragma once
22+
23+
#include "../include/Version.h"
24+
25+
#include <WinStd/Common.h>
26+
#include <WinStd/Win.h>
27+
28+
#include <Windows.h>
29+
#include <Msi.h>
30+
#include <tchar.h>
31+
32+
#include <memory>

VS10Solution.sln

+11
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TLS_UI", "lib\TLS_UI\build\
3838
EndProject
3939
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TTLS_UI", "lib\TTLS_UI\build\TTLS_UI.vcxproj", "{42F0F0F4-C928-4860-A4E4-94991C2C3D90}"
4040
EndProject
41+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MsiUseFeature", "MsiUseFeature\MsiUseFeature.vcxproj", "{679D03C5-CD70-4FFA-93F8-A4AB3637509B}"
42+
EndProject
4143
Global
4244
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4345
Debug|Win32 = Debug|Win32
@@ -150,6 +152,14 @@ Global
150152
{42F0F0F4-C928-4860-A4E4-94991C2C3D90}.Release|Win32.Build.0 = Release|Win32
151153
{42F0F0F4-C928-4860-A4E4-94991C2C3D90}.Release|x64.ActiveCfg = Release|x64
152154
{42F0F0F4-C928-4860-A4E4-94991C2C3D90}.Release|x64.Build.0 = Release|x64
155+
{679D03C5-CD70-4FFA-93F8-A4AB3637509B}.Debug|Win32.ActiveCfg = Debug|Win32
156+
{679D03C5-CD70-4FFA-93F8-A4AB3637509B}.Debug|Win32.Build.0 = Debug|Win32
157+
{679D03C5-CD70-4FFA-93F8-A4AB3637509B}.Debug|x64.ActiveCfg = Debug|x64
158+
{679D03C5-CD70-4FFA-93F8-A4AB3637509B}.Debug|x64.Build.0 = Debug|x64
159+
{679D03C5-CD70-4FFA-93F8-A4AB3637509B}.Release|Win32.ActiveCfg = Release|Win32
160+
{679D03C5-CD70-4FFA-93F8-A4AB3637509B}.Release|Win32.Build.0 = Release|Win32
161+
{679D03C5-CD70-4FFA-93F8-A4AB3637509B}.Release|x64.ActiveCfg = Release|x64
162+
{679D03C5-CD70-4FFA-93F8-A4AB3637509B}.Release|x64.Build.0 = Release|x64
153163
EndGlobalSection
154164
GlobalSection(SolutionProperties) = preSolution
155165
HideSolutionNode = FALSE
@@ -168,5 +178,6 @@ Global
168178
{9A25C261-8ADE-4938-8393-E857EF0E37E9} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393}
169179
{42F0F0F4-C928-4860-A4E4-94991C2C3D90} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393}
170180
{2D3CE079-7EB1-4F47-B79E-F0310671ECCB} = {7B5EC9B7-208C-426A-941D-DAF9271BD4A4}
181+
{679D03C5-CD70-4FFA-93F8-A4AB3637509B} = {7B5EC9B7-208C-426A-941D-DAF9271BD4A4}
171182
EndGlobalSection
172183
EndGlobal

0 commit comments

Comments
 (0)