我有一个PathEdit控件用于我打算分享的文件夹。我想允许用户 在相同的PathEdit控件(支持)中输入UNC路径。
问题是,当输入UNC路径时,在安装过程中它会尝试共享它。
如果是UNC路径,怎么能不分享?
以下是代码段:
PathEdit控件定义:
<!-- Target audio files directory -->
<Control Id="lblAudioFilesDirectory" Type="Text" X="20" Width="100" Y="135" Height="18" NoPrefix="yes" Text="!(loc.AudioFilesDirectoryLabel)" />
<Control Id="peAudioFilesDirectory" Type="PathEdit" X="120" Width="180" Y="135" Height="18" Property="PROP_AUDIODIR" Indirect="yes" />
<Control Id="btnAudioFilesDirectory" Type="PushButton" X="305" Width="20" Y="135" Height="18" Text="!(loc.Browse)">
<Publish Property="_BrowseProperty" Value="[PROP_AUDIODIR]" Order="1">1</Publish>
<Publish Event="SpawnDialog" Value="Custom_BrowseDlg" Order="2">1</Publish>
</Control>
目录片段:
<Directory Id="AUDIOFOLDER" Name="AudioFiles">
<Component Id="cmpAUDIOFOLDER" Guid="{8BCFBEA2-9E7B-4E45-8838-6A71216C9B20}">
<CreateFolder />
<util:User Id="Everyone" Name="Everyone"></util:User>
<util:FileShare Id="fsAudioFiles" Description="Audio files" Name="AudioFiles">
<util:FileSharePermission User="Everyone" GenericAll="yes" />
</util:FileShare>
</Component>
</Directory>
我可以在
上做一些有条件的工作吗?<util:User Id="Everyone" Name="Everyone"></util:User>
<util:FileShare Id="fsAudioFiles" Description="Audio files" Name="AudioFiles">
<util:FileSharePermission User="Everyone" GenericAll="yes" />
</util:FileShare>
只有在路径不是UNC时才能使它工作?
答案 0 :(得分:2)
Component
是Windows安装程序中安装的原子单位,因此您需要Condition
。假设相关文件夹的Directory/@Id
为AudioFiles
,您可以执行以下操作:
<Component Id="cmpAUDIOFOLDER" Guid="PUT-GUID-HERE"
Directory="AudioFiles">
<!-- If the AudioFiles directory starts with a double backslash, it's a network
share, so share it with everyone. -->
<Condition>AudioFiles << "\\"</Condition>
<CreateFolder />
<util:FileShare Id="fsAudioFiles" Description="Audio files" Name="AudioFiles">
<util:FileSharePermission User="Everyone" GenericAll="yes" />
</util:FileShare>
</Component>