Inno Setup中的Windows帐户查询列表 [英] Query list of Windows accounts in Inno Setup
本文介绍了Inno Setup中的Windows帐户查询列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的Inno Setup项目中,我需要允许用户从自定义页面上的所有本地帐户列表中选择一个帐户.所选帐户将用于安装具有自定义凭据的服务.我该怎么做?
提前谢谢!
解决方案
您可以使用
相关问题:
In my Inno Setup project I need to allow the user to choose an account from the list of all local accounts on a custom page. The selected account will be used to install a service with custom credential. How can I make this?
Thank you in advance!
解决方案
You can use WMI Win32_UserAccount
class to query the list of accounts.
[Run]
Filename: sc.exe; Parameters: ... {code:GetAccount}
[Code]
var
AccountPage: TInputOptionWizardPage;
procedure InitializeWizard();
var
WMIService: Variant;
WbemLocator: Variant;
WbemObjectSet: Variant;
I: Integer;
begin
Log('InitializeWizard');
AccountPage := CreateInputOptionPage(
wpSelectTasks, 'Service account', '', 'Please select account for the service:',
True, True);
WbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
WMIService := WbemLocator.ConnectServer('localhost', 'root\CIMV2');
WbemObjectSet :=
WMIService.ExecQuery('SELECT * FROM Win32_UserAccount');
if not VarIsNull(WbemObjectSet) then
begin
for I := 0 to WbemObjectSet.Count - 1 do
begin
AccountPage.Add(WbemObjectSet.ItemIndex(I).Caption);
end;
AccountPage.SelectedValueIndex := 0;
end;
end;
function GetAccount(Param: string): string;
var
I: Integer;
begin
for I := 0 to AccountPage.CheckListBox.Items.Count - 1 do
begin
if AccountPage.Values[I] then Result := AccountPage.CheckListBox.Items[I];
end;
end;
Related questions:
- Inno Setup Create individual shortcuts on all desktops of all users
- Inno Setup to create a user in Windows
这篇关于Inno Setup中的Windows帐户查询列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文