gpt4 book ai didi

delphi - 如何显示 Windows 安全对话框

转载 作者:行者123 更新时间:2023-12-03 15:53:51 26 4
gpt4 key购买 nike

我有一个应用程序有时会访问本地网络中的文件共享。在这种情况下,路径存储在 fEBookPath 中。如果用户输入登录名和密码,那么一切都很好。但如果不是 FindFirst 则不返回 0。在这种情况下,我想显示与 Windows 资源管理器显示的相同的安全对话框。像这样

enter image description here

我的简化代码

if FindFirst(fEBookPath + '*.*', faDirectory, vSearchRecFolder) = 0 then
begin
// Existing code to access fEBookPath
end
else
// Display Windows security dialog to enter login + password

最佳答案

这段代码应该做我想要的事情

function TLogonForm.ShowSecurity: DWORD;
var
UNCPath,UserName,PassWord: string;
NwR : TNetResource;
begin
UNCPath := '\\xenapp06';
NwR.lpLocalName:= '';
NwR.lpProvider := '';
NwR.dwType := RESOURCETYPE_DISK;
NwR.lpRemoteName:= PChar(UNCPath);
Result := WNetAddConnection2(NwR, nil, nil, CONNECT_INTERACTIVE or CONNECT_PROMPT);
end;

关于delphi - 如何显示 Windows 安全对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45141561/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com