Visual Studio 2010 — окно списка Значение свойства не приходит в c ++ пользовательское действие wix?

Я застрял с этим довольно долго, свойство ListBox «SETUPLOGLEVEL» не показывает значение в пользовательском действии C ++, когда я вызываю MsiGetProperty (hInstall, L «SETUPLOGLEVEL», Pid, &PidLength). Pid также показывает значение 0 после выполнения этой функции, я проверил отладку пользовательского действия.
Это Product.wxs

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>

<Product Id="*" Name="MyExampleProject" Language="1033" Version="1.0.0.0" Manufacturer="Mq" UpgradeCode="08bd3c48-deef-4370-ab94-f8b4d49406e3">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" InstallPrivileges="elevated"/>

<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<!--System Configuration Condition - Installation install only above Windows XP-->

<Condition Message="This application is only supported on Windows XP, or higher.">
<![CDATA[Installed OR (VersionNT >= 501)]]>
</Condition>

<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='ProgramFilesFolder' Name='PFiles'>
<Directory Id='INSTALLDIR' Name='AgentFramework'>
<Directory Id='INSTALLBIN' Name='bin'/>
<Directory Id='INSTALLCONF' Name='conf'/>
<Directory Id='INSTALLMODULES' Name='modules'/>
</Directory>
</Directory>
</Directory>
<Feature
Id = "ProductFeature1"Title  = "AgentFramework"Level  = "1"Absent="allow">

<ComponentRef Id='libapr_dll'/>
<ComponentRef Id='libapriconv_dll'/>
<ComponentRef Id='libaprutil_dll'/>
<ComponentRef Id='libhttpd_dll'/>
<ComponentRef Id='Pcre_dll'/>
<ComponentRef Id='Configurationfile'/>
<ComponentRef Id='Authzmodule'/>
<ComponentRef Id='Dirmodule'/>
<ComponentRef Id='ServiceComponent'/>
</Feature>

<DirectoryRef Id='INSTALLCONF'>
<Component Id='Configurationfile' Guid='2E0D2957-10EB-463A-A4FC-62B9062FE8A3'>
<File Id='Configurationfile' Name='httpd.conf' DiskId='1' Source='$(sys.CURRENTDIR)\httpd.conf' KeyPath='yes'>
</File>
</Component>
</DirectoryRef>
<DirectoryRef Id='INSTALLMODULES'>
<Component Id='Authzmodule' Guid='62AA97B6-7821-4CB4-9F89-B2A8FF0CC6BD'>
<File Id='Authzmodule' Name='mod_authz_core.so' DiskId='1' Source='$(sys.CURRENTDIR)\mod_authz_core.so' KeyPath='yes'>
</File>
</Component>
<Component Id='Dirmodule' Guid='9966BB3B-8296-43B9-A6DC-712561303329'>
<File Id='Dirmodule' Name='mod_dir.so' DiskId='1' Source='$(sys.CURRENTDIR)\mod_dir.so' KeyPath='yes'>
</File>
</Component>
</DirectoryRef>
<DirectoryRef Id='INSTALLBIN'>
<Component Id='libapr_dll' Guid='FB82D093-0B32-465B-8D8B-08B3127EB414'>
<File Id='libapr_dll' Name='libapr-1.dll' DiskId='1' Source='$(sys.CURRENTDIR)\libapr-1.dll' KeyPath='yes'>
</File>
</Component>
<Component Id='libapriconv_dll' Guid='667D6D5B-6FE4-4A6B-827F-C496239628E2'>
<File Id='libapriconv_dll' Name='libapriconv-1.dll' DiskId='1' Source='$(sys.CURRENTDIR)\libapriconv-1.dll' KeyPath='yes'>
</File>
</Component>
<Component Id='libaprutil_dll' Guid='72C688D2-8E25-49D9-9E76-F6BDBC33D394'>
<File Id='libaprutil_dll' Name='libaprutil-1.dll' DiskId='1' Source='$(sys.CURRENTDIR)\libaprutil-1.dll' KeyPath='yes'>
</File>
</Component>
<Component Id='libhttpd_dll' Guid='8946D5B1-0EA2-443E-8C20-CD8D877ACF75'>
<File Id='libhttpd_dll' Name='libhttpd.dll' DiskId='1' Source='$(sys.CURRENTDIR)\libhttpd.dll' KeyPath='yes'>
</File>
</Component>
<Component Id='Pcre_dll' Guid='0466BB2A-137C-4A95-A510-43E7A274F834'>
<File Id='Pcre_dll' Name='pcre.dll' DiskId='1' Source='$(sys.CURRENTDIR)\pcre.dll' KeyPath='yes'>
</File>
</Component>
<Component Id ="ServiceComponent" Guid="8A1BF3F0-8A84-456E-816A-5907B40B2DDB" >
<File Id='Applicationfile' Name='httpd.exe' DiskId='1' Source='$(sys.CURRENTDIR)\httpd.exe' KeyPath='yes'>
</File>
<ServiceInstall Id="ServiceComponent" Type="ownProcess" Name="Apache2.4"DisplayName="Apache2.4" Description="Service"Arguments="-k runservice" Start="auto"  Account="LocalSystem" ErrorControl="normal"Vital="yes" >
<util:PermissionEx  User="Everyone" ServicePauseContinue="yes" ServiceQueryStatus="yes"ServiceStart="yes" ServiceStop="yes" ServiceUserDefinedControl="yes" /> </ServiceInstall><ServiceControl Id="ServiceComponent" Start="install" Stop="both"Remove="uninstall" Name="Apache2.4" Wait="yes" />
</Component>
</DirectoryRef>
<UIRef Id="CustomizeDlg" />

<UI Id="MyWixUI_Mondo">
<UIRef Id="WixUI_Mondo" />
<UIRef Id="WixUI_ErrorProgressText" />

<DialogRef Id="UserRegistrationDlg" /><Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="UserRegistrationDlg" Order="3">LicenseAccepted = "1"</Publish>
<Publish Dialog="SetupTypeDlg" Control="Back" Event="NewDialog" Value="UserRegistrationDlg">1</Publish>
</UI>
<Property Id="PIDTemplate"><![CDATA[1234<####-####-####-####>@@@@]]></Property>

<CustomAction Id='CheckLogLevel' BinaryKey='CheckLogLevel' DllEntry='CustomAction1' />
<Binary Id ='CheckLogLevel' SourceFile='$(sys.CURRENTDIR)\MqAgent_LogLevel.dll'/>
<WixVariable Id="WixUIBannerBmp" Value="C:\Image\style39_banner.bmp" />
<WixVariable Id="WixUIDialogBmp" Value="C:\Image\style39_dialog.bmp" />
</Product>
</Wix>

Вот мой код CustomizeDlg.wxs ::

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<UI Id ="CustomizeDlg"><Dialog Id="UserRegistrationDlg" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes">
<Control Id="MyListBox"Type="ListBox"  X="52" Y="48"Width="100" Height="45"Property="SETUPLOGLEVEL" Sorted="yes">

<ListBox Property="SETUPLOGLEVEL">

<ListItem Text="Debug"  Value="1" />

<ListItem Text="info" Value="2" />

<ListItem Text="warn" Value="3" />

</ListBox>
<Property Id="SETUPLOGLEVEL" Value="1"/>

</Control>
<Control Id="CDKeyLabel" Type="Text" X="45" Y="147" Width="50" Height="10" TabSkip="no">
<Text>CD &amp;Key:</Text>
</Control>
<Control Id="CDKeyEdit" Type="MaskedEdit" X="45" Y="159" Width="250" Height="16" Property="PIDKEY" Text="[PIDTemplate]" />
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&amp;Back">
<Publish Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
</Control>
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="&amp;Next">
<Publish Event="ValidateProductID" Value="0">1</Publish>
<Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg">CostingComplete = 1</Publish>
<Publish Event="NewDialog" Value="SetupTypeDlg">ProductID</Publish>
</Control>
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
</Control>
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="WixUI_Bmp_Banner" />
<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes">
<Text>Please mention the log level</Text>
</Control>
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes">
<Text>{\WixUI_Font_Title}Select Log Level</Text>
</Control>
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
</Dialog>
</UI>
</Fragment>
</Wix>

И это мое пользовательское действие:

#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>

using namespace std;

UINT __stdcall CustomAction1(MSIHANDLE hInstall)
{
HRESULT hr = S_OK;
UINT er = ERROR_SUCCESS;
string search_string;
string replace_string;
string inbuf;

DWORD PidLength         = MAX_PATH;

wchar_t Pid[MAX_PATH]   = {L"0"};

MessageBox(NULL,L"debug", L"CustomactionDebug", MB_OK);hr = WcaInitialize(hInstall, "CustomAction1");
ExitOnFailure(hr, "Failed to initialize");
WcaLog(LOGMSG_STANDARD, "Initialized.");

MsiGetProperty(hInstall, L"SETUPLOGLEVEL", Pid, &PidLength);LExit:
er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
return WcaFinalize(er);
}// DllMain - Initialize and cleanup WiX custom action utils.
extern "C" BOOL WINAPI DllMain(
__in HINSTANCE hInst,
__in ULONG ulReason,
__in LPVOID
)
{
switch(ulReason)
{
case DLL_PROCESS_ATTACH:
WcaGlobalInitialize(hInst);
break;

case DLL_PROCESS_DETACH:
WcaGlobalFinalize();
break;
}

return TRUE;
}

0

Решение

Я не могу сказать, где или как вызывается ваш ЦС, но я могу подумать о двух возможных причинах:

  1. Вы вызываете его из отложенного настраиваемого действия, а это значит, что вам нужно использовать CustomActionData для получения значения.

  2. Свойство не помечено как Secure = «yes», поэтому оно теряет свое значение к тому времени, когда вы вызываете свой CA в последовательности выполнения.

1

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]