IsIconic、CenterWindow()的用法 、LockWindowUpdate、CredUIParseUserName


一、Isiconic

功能 函数功能:该函数确定给定窗口是否是最小化(图标化)的窗口。函数原型:BOOL IsIconic(HWND hWnd);


hWnd:被测试 窗口的句柄。
返回值:如果 窗口未最小化,返回值为零;如果窗口已最小化,返回值为非零。

函数isiconic返回值取决于指定窗口是否已经最小化。

BOOL IsIconic(
    HWND hWnd  // handle of window
   ); 

二、 CenterWindow()的用法 

CenterWindow()的用法为: 

void CenterWindow( CWnd* pAlternateOwner = NULL ); 

其中参数pAlternateOwner指向所想居中的窗口的指针。 
然后利用函数GetSystemMetrics( int nIndex )得到系统当前设置如屏幕分辨率等。 
nIndexs= SM_CXSCREEN 时函数返回屏幕的宽度;返回值单位为像素点。 
nIndexs= SM_CYSCREEN 时函数返回屏幕的高度;返回值单位为像素点。 
函数BOOL GetWindowPlacement( WINDOWPLACEMENT* lpwndpl ) 是最重要的。他的参数为一个指向结构变量WINDOWPLACEMENT的指针(lpwndpl);其中WINDOWPLACEMENT结构变量数据结构具体为: 

typedef struct tagWINDOWPLACEMENT { /* wndpl */ 
UINT length; 
UINT flags; 
UINT showCmd; 
POINT ptMinPosition; 
POINT ptMaxPosition; 
RECT rcNormalPosition; 
} WINDOWPLACEMENT; 

他包含了窗口在屏幕上的定位信息

其中成员变量的含义为: 
length:指结构变量的长度,单位字节。 
flags: 标志值,控制窗口最小化或窗口还原的方法,可以取如下值: 
WPF_SETMINPOSITION:指定窗口最小化时的x位置和y位置。 
WPF_RESTORETOMAXIMIZED:指定窗口以最大化方式还原,尽管可能窗口并不是在最大化时最小化的。不改变窗口的缺省还原方式。 
showCmd:指定窗口的当前显示状态。可以取值: 
SW_HIDE:隐藏窗口并激活另一窗口。 
SW_MINIMIZE:最小化指定窗口并激活系统窗口列表中最顶层窗口。 
SW_RESTORE:激活并显示窗口,如果窗口处于最小化或最大化状态,则窗口还原到原始大小和位置。 
SW_SHOW:以窗口的当前大小和位置激活并显示窗口。 
SW_SHOWMAXIMIZED:以最大化方式激活并显示窗口。 
SW_SHOWMINIMIZED:以图标方式激活并显示窗口。 
SW_SHOWMINNOACTIVE:以图标方式窗口。 但不改变窗口的活动状态。 
SW_SHOWNA:以窗口的当前状态显示窗口。 
SW_SHOWNOACTIVATE:以窗口最近一次的大小和位置显示窗口。 但不改变窗口的活 动状态。 
SW_SHOWNORMAL:激活并显示窗口。如果窗口被最大化或最小化,则窗口还原到原始大小和位置。 
ptMinPosition:指定窗口最小化时的左上角坐标。 
ptMaxPosition:指定窗口最大化时的左上角坐标。 
rcNormalPosition:指定窗口在还原时的坐标。 
通过灵活使用函数GetWindowPlacement()就可以得到窗口的配置信息。 
看到这,可能有些读者已经想到了GetWindowPlacement()函数的姐妹函数SetWindowPlacement(),不用多说,其用法如下: 
BOOL SetWindowPlacement( WINDOWPLACEMENT* lpwndpl ); 
显然,通过函数SetWindowPlacement(),再加以简单的计算,我们就可以来设置窗口的位置、大小以及状态等,从而可以自如地控制窗口显示与否以及窗口的大小、位置等


GetWindowPlacement

函数功能:该函数返回指定窗口的显示状态以及被恢复的、最大化的和最小化的窗口位置
函数原型:BOOL GetWindowPlacement(HWND hWnd,WINDOWPLACEMENT *lpwndpl);
参数:
hWnd: 窗日句柄。
lpwndpl:指向WINDOWPLACEMENT结构的指针,该结构存贮显示状态和位置信息。
在调用GetWindowPlacement函数之前,将WINDOWPLACEMENT结构的长度设为sizeof(WIDNOWPLACEMENT)。如果lpwndpl->length设置不正确则函数GetWindowPlacement将失败。
返回值;如果函数成功,返回值为非零;如果函数失败,返回值为零。若想获得更多错误信息,请调用GetlastError函数。
备注:由该函数获得的WINDOWPLACEMENT结构的flag单元总为0。如果hWnd的窗口被最大化,则showCmd元为 SHOWMZAXMIZED,如果窗口被最小化,则showCmd元为SHOWMINIMIZED,除此之外为SHOWNORMN, WINDOWPLACEMENT长度单元必须置为sizeOf( WINDOWPLACEMENT),如果参数设置不正确,函数返回FALSE。查看设置窗口位置坐标的正确信息,参看WINDOWPLACEMENT。


三、LockWindowUpdate

LockWindowUpdate做的事情其实很简单。当一个窗口被“锁定”,所有向它及其子窗口的绘制都会失败。取代绘制操作的是,窗口管理器记住了应用程序试图在窗口的哪一部分中进行绘制。当窗口“解锁”后,这些区域被无效化,使得应用程序得到一个WM_PAINT消息,从而重新恢复了屏幕内容与应用程序认为应当在屏幕上显示的内容之间的同步。

大家已经在CS_SAVEBITS看到了“记录在情形X有效时,应用程序试图做的绘制,并在情形X不再有效时做无效处理”这样的行为。在这种意义上,LockWindowUpdate做了同样的簿记的工作。在你用一个CS_SAVEBITS窗口覆盖锁定的窗口时这个行为就会发生,只是这里不会保存什么数据。
 
在文档中明确的指出,同一时间只能有一个窗口被锁定。同时这也可以由函数原型暗示得出。如果两个窗口可以同时被锁定,将无法可靠的使用LockWindowUpdate。当你做下面的事情时将会怎样:
LockWindowUpdate(hwndA); // 锁定窗口A
LockWindowUpdate(hwndB); // 将窗口B也锁定
LockWindowUpdate(NULL); // ???
 
第三个对LockWindowUpdate的调用会做什么么?是把所有的窗口解锁?还是只解锁窗口A,或是只解锁窗口B?不论你如何回答,都不可能让下列的代码可靠的使用LockWindowUpdate:
void BeginOperationA()
{
 LockWindowUpdate(hwndA);
 ...
}
 
void EndOperationA()
{
 ...
 LockWindowUpdate(NULL);
}
 
void BeginOperationB()
{
 LockWindowUpdate(hwndB);
 ...
}
 
void EndOperationB()
{
 ...
 LockWindowUpdate(NULL);
}

设想BeginOperation开始了由异步行为触发的某个操作。例如,假设操作绘制播放的反馈,因此开始于鼠标按下,并结束于鼠标释放。
 
现在假设仍在播放过程中时,操作B结束了。EndOperationB将会清理操作B,并调用LockWindowUpdate(NULL)。如果你假设这将解锁所有窗口,那么就会破坏了操作A,因为它预期hwndA仍被锁定。类似的,如果你提出应当只解锁hwndA,那么不只操作A被破坏了,操作B也会被破坏(因为尽管操作B已经完成,hwndB仍被锁定)。另一方面,如果你建议LockWIndowUpdate(NULL)应当解锁hwndB,那么请考虑一下操作A先于B完成的情况。
 
如果LockWindowUpdate同一时间能够锁定多于一个窗口,那么这个函数的原型就需要修改,以使得解锁的操作可以知道那一个窗口正在被解锁。有很多方法可以做到这一点,例如添加一个新的参数或是创建一个单独的函数。
// 方法A – 新参数
// fLock = TRUE 锁定, FALSE 解锁
BOOL LockWindowUpdate(HWND hwnd, BOOL fLock);
 
// 方法B – 独立函数
BOOL LockWindowUpdate(HWND hwnd);
BOOL UnlockWindowUpdate(HWND hwnd);
 
但是这两个都不是实际的情况,LockWindowUpdate函数同一时间只锁定一个窗口。这样做的原因在了解了LockWindowUpdate是用来做什么的之后会更加清晰





LockWindowUpdate系列2:LockWindowUpdate是打算如何使用的?

现在我们知道了LockWindowUpdate的行为。现在我们来看一下它是用于做什么的。
 
事实上,LockWindowUpdate的设计意图可以用一个词表达:拖拽。但我们稍后再说到这个。
 
LockWindowUpdate 的目的是允许一个程序暂时的接管绘制窗口的工作。为了做到这个,你当然需要防止窗口函数(或其它任何人)进行他们正常的绘制活动;否则,两处的代码(正常绘制窗口的代码和试图接管绘制的代码)会互相争夺对窗口的控制,由于互不知道对方在做什么,最后得到的将是一团糟。
 
但是,如果你已经锁定了窗口的更新,那么如何才能在窗口上绘制呢?你可以在GetDCEx函数中使用DCX_LOCKWINDOWUPDATE标志。这个标志表示“即便是窗口已经锁定,也让我绘制到上面”。当然了,只有锁定了这个窗口的代码才能传递这个标志,否则又会引发LockWindowUpdate起初试图解决的那类冲突。
 
由于人们都很喜欢看表格,我制作了一个表格总结了当一个窗口被锁定更新时发生了什么变化。
 
正常行为更新被锁定
BeginPaintGetDC,等等…绘制操作绘制到窗口上绘制操作没有在窗口上绘出任何东西,但影响的区域被记录下来以供后面无效化
带DCX_LOCKWINDOWUPDATE标志的GetDCEx(不要使用)绘制操作绘制到窗口上
  
换句话说,当一个窗口更新被锁定后,普通的DC获取函数(BeginPaint及其伙伴)向窗口上绘制的能力将被剥夺,赋于了GetDCEx( DCX_LOCKWINDOWUPDATE) 。注意,如果没有窗口被锁定更新,不要使用DCX_LOCKWINDOWUPDATE标志,这个标志的目的是指出“我就是那个调用了LockWindowUpdate的家伙,快放行!”
 
窗口管理器有几分像喜剧中的情节。你告诉守卫说“不许任何人进入这个房间。”一小时后你回来了,守卫不让你进去。
“对不起先生,我不能让任何人进这个房间。”
“但我就是那个告诉你不让任何人进去的人呀。”
“是的,先生,我是按照您的指示做的。任何人都不能进入这个房间。” 
错误在于最初给守卫下达的命令。你应当说:“除了我以外,任何人都不允许进入这个房间。”  DCX_LOCKWINDOWUPDATE就好比你对窗口管理器说:“是我,让我进去。”
 
如果回头看一下LockWindowUpdate函数的工作方式,你会发现如果一个锁定的窗口没有试图做任何绘制,那么当窗口解锁时,不会有区域被无效。尽管 CS_SAVEBITS 窗口类属性会在窗口从屏幕上移除时自动保存原始的象素,并自动还原这些象素,LockWindowUpdate不会做任何类似的事。你需要自己负起责任确保在窗口被锁定更新时你修改的象素,在调用LockWindowUpdate(NULL)后恢复到原始的值。这通常可以通过在做自己的绘图操作前,将原始象素保存到一个屏幕外的位图中,并在完成后将它们绘制回去。
 
好,那么下面这就是意图的使用方式:
 
  • 当你想接管另一个窗口的绘制,对那个窗口调用LockWindowUpdate。
  • 保存你将要覆盖绘制的窗口的象素。
  • 绘制新的象素(这些象素往往是原始象素的修正,比如在将一个对象拖动到一个窗口上方时,你可能会添加一个表示此对象的图片)。
  • 只要你的操作还在进行中,尽管重复。(这么做时,如果你正修改的屏幕区域与之前修改的不同,可能需要“备份”更多的屏幕上的象素。你可以增量的做备份/还原。例如,你不必在绘制新图片前累计需要恢复的象素集,只需要先把保存的所有象素恢复到屏幕,然后计算拖动图片的新位置,保存新位置处的象素,接着就可以在新位置绘制新图片。通过这种方式,你只需要处理一组“备份象素”)
  • 当操作完成,恢复原始象素,并调用LockWindowUpdate(NULL)。

 

下一篇,我们将看到“拖拽”这个词的更多内容,以其是如何紧密的与整个LockWindowUpdate的概念绑定在一起的。
 
尽管我们才刚刚开始讨论LockWindowUpdate,你应当已经足以回管这个问题。
 
(注意:写这个系列的目的在于描述LockWindowUpdate的意图使用方式,不是讨论这首先是不是一个好的设计)



LockWindowUpdate系列3:什么样的操作中应当使用LockWindowUpdate?

如我在前面所说的,LockWindowUpdate的设计意图可以用一个词表达:拖拽。
LockWindowUpdate 最简单的使用场景是在“拖动时显示窗口内容”功能关闭的情况下,当你移动或是改变窗口尺寸时,被窗口管理器使用。当你开始移动/改变尺寸操作,窗口管理器锁定整个桌面以便可以绘制细点矩形反馈,而不会因为其它窗口偶然与细点矩形交叠而导致冲突的风险。当移动/改变尺寸的操作完成,桌面被解锁,所有东西恢复原貌。
 
应用程序使用LockWindowUpdate的常见的场景,是希望为拖拽提供反馈而绘制一个自定义的图片。在这个情况下,应用程序锁定它自己的窗口以绘制拖拽的反馈。使用 DCX_LOCKWINDOWUPDATE 标志来获取一个可以用来绘制所需的反馈的DC,这样就不必担心窗口函数或应用程序中任何其它的代码偶然的绘制到反馈窗口上,并搞乱了拖拽图片。例如,如果这个应用程序正在一个列表视图中绘制拖拽的反馈,此时某个异步事件引发这个列表视图的内容改变(比方说添加了一个列表项),并且拖拽的图片正好在新添加的列表项要出现的位置,你一定不会想让列表视图的标准重绘行为覆盖(或是更糟,重合)了拖拽的图片。
 
可能你需要锁定其它应用程序的窗口的场景是当你要把一个物体拖过整个屏幕。如果你的程序是一个类似Spy那样的程序,允许用户通过拖拽一个“选择器”到一个窗口上方来选择它时,你可能会需要这么做。你需要锁定用户当前选择的窗口,不仅让它自己的重绘制不会与你的“选择器”冲突,也使其不会与你放置在窗口边沿的高亮效果冲突
 
现在,你可能已经注意到所有使用LockWindowUpdate场景中一个共同的思路:他们都和某种形式的拖拽有关。拖拽窗口的标题以移动它、拖拽窗口的边框以改变它的尺寸、将一个对象拖入窗口或是拖出窗口。这不是一个巧合,LockWindowUpdate就是专门设计用于这些拖拽场景的。由于拖拽对象要用到鼠标按键,而只会有一个鼠标,故而同一时间不会有多个拖拽操作进行。因此,没有必要同时锁定多个窗口的更新。也许这个函数应当更准确的命名为LockDragWindow



LockWindowUpdate系列4:什么样的操作中不应当使用LockWindowUpdate?

那么,现在我们已经知道了 什么样的操作中应当使用LockWindowUpdate ,现在我们来看一下人们在一些与拖拽无关的工作中错误使用这个函数的方式。
 
人们看到LockWindowUpdate“锁定的窗口将不能绘制自己”的行为,就用它来作为 WM_SETREDRAW 消息的偷懒的使用方式,尽管发送一个WM_SETREDRAW消息不不比调用LockWindowUpdate更麻烦。只是多打20来个字符,而且如果使用<windows.h>中的SetWindowRedraw宏的话还少会一半。
不使用LockWindowUpdate(hwnd)
代而使用SendMessage(hwnd, WM_SETREDRAW, FALSE, 0) or
SetWindowRedraw(hwnd, FALSE)
 
不使用LockWindowUpdate(NULL)
代而使用SendMessage(hwnd, WM_SETREDRAW, TRUE, 0) or
SetWindowRedraw(hwnd, TRUE)

就像我们在前面所说的,同一时间系统中只能有一个窗口的更新被锁定。如果你调用LockWindowUpdate的目的仅仅是防止窗口重绘,比如因为你在更新这个窗口,在你的更新完成前,不希望它不停的刷新,那么请直接禁止窗口的重绘。如果你使用了LockWindowUpdate,将引来无数下面的问题
 
首先,如果另一个什么程序也以同样错误的方式使用LockWindowUpdate,那么你们中会有一个人失败。首先调用LockWindowUpdate的程序将会成功,第二个调用的程序将会失败。现在你准备怎么办?你的窗口不会被锁定。
 
其次,如果你锁定了自己的窗口更新,这时用户切换到另一个程序,并试图拖拽一个对象(或甚至只是尝试移动一下那个窗口),那一个LockWindowUpdate将会失败,于是用户遇到了一个由于某种神秘原因拖放失效的情形。然后,10秒钟后,一切功能又运作作正常。“愚蠢的烂Windows”用户嘀咕道。
 
反过来说,如果 你在一个拖放或是窗口移动的过程中准备调用LockWindowUpdate,那么你的调用就会失败
 
这只是更一般意义上,使用全局状态来处理局部情况的编程错误中,比较具体的例子。当你想禁止自己的一个窗口的重绘时,你不会希望这会影响到系统中的其它窗口。更新自己的窗口是一个局部情况,但是你使用了全局状态(被锁定更新的窗口)来维持它。
 
我可以预料到有人会说:“那么,窗口管理器应当阻止人们在一个非拖放操作中锁定窗口更新。”问题是,窗口管理器怎么知道这个?它只是知道发生了什么事情,但不知道为什么发生。一个程序到底是由于懒于使用WM_SETREDRAW消息而使用LockWindowUpdate?还是为了响应引发拖放操作的用户输入?这里没办法说“用户鼠标按键压下了”,因为用户可能用基于键盘的理论上和拖放等价的操作(例如使用方向键来改变窗口尺寸)。基本上这个问题很难于解决,除非计算机能更多一点对让他做的事情的猜想。
 
下一回是对LockWindowUpdate的最终评论。



四、 CredUIParseUserName


在C:\Windows\System32\credui.dll文件中的接口。

The  CredUIParseUserName  function extracts the domain and user account name from a fully qualified user name.
CredUIParseUserName用于从一个合格的用户服务名串中解析域名和用户名。
DWORD WINAPI CredUIParseUserName(
  _In_   PCTSTR pszUserName,
  _Out_  PTSTR pszUser,
  _In_   ULONG ulUserMaxChars,
  _Out_  PTSTR pszDomain,
  _In_   ULONG ulDomainMaxChars
);

Parameters

pszUserName [in]

Pointer to a null-terminated string that contains the user name to be parsed. The name must be in UPN or down-level format, or a certificate. Typically, pszUserNameis received from the CredUIPromptForCredentials or CredUICmdLinePromptForCredentials.

pszUser [out]

Pointer to a null-terminated string that receives the user account name.

ulUserMaxChars [in]

Maximum number of characters to write to the pszUser string including the terminating null character.

Note  CREDUI_MAX_USERNAME_LENGTH does NOT include the terminating null character.

pszDomain [out]

Pointer to a null-terminated string that receives the domain name. If pszUserName specifies a certificate, pszDomain will be NULL.

ulDomainMaxChars [in]

Maximum number of characters to write to the pszDomain string including the terminating null character.

Note  CREDUI_MAX_DOMAIN_TARGET_LENGTH does NOT include the terminating null character.

Return value

This function returns the following:

  • NO_ERROR

    The user name is valid.

  • ERROR_INVALID_ACCOUNT_NAME

    The user name is not valid.

  • ERROR_INSUFFICIENT_BUFFER

    One of the buffers is too small.

  • ERROR_INVALID_PARAMETER
    • ulUserMaxChars or ulDomainMaxChars is zero.
    • pszUserNamepszUser, or pszDomain is NULL.

Remarks

This function parses the user name information returned by the CredUIPromptForCredentials and CredUICmdLinePromptForCredentials functions so that the resulting credentials can be passed to functions, such as LogonUser, that require the user name and domain as separate strings.

CredUIPromptForCredentials function

The CredUIPromptForCredentials function creates and displays a configurable dialog box that accepts credentials information from a user.

Applications that target Windows Vista or Windows Server 2008 should call CredUIPromptForWindowsCredentials instead of this function, for the following reasons:

DWORD WINAPI CredUIPromptForCredentials(
  _In_opt_  PCREDUI_INFO pUiInfo,
  _In_      PCTSTR pszTargetName,
  _In_      PCtxtHandle Reserved,
  _In_opt_  DWORD dwAuthError,
  _Inout_   PCTSTR pszUserName,
  _In_      ULONG ulUserNameMaxChars,
  _Inout_   PCTSTR pszPassword,
  _In_      ULONG ulPasswordMaxChars,
  _Inout_   PBOOL pfSave,
  _In_      DWORD dwFlags
);

Parameters

pUiInfo [in, optional]

A pointer to a CREDUI_INFO structure that contains information for customizing the appearance of the dialog box.

pszTargetName [in]

A pointer to a null-terminated string that contains the name of the target for the credentials, typically a server name. For Distributed File System (DFS) connections, this string is of the form ServerName\ShareName. This parameter is used to identify target information when storing and retrieving credentials.

Reserved [in]

This parameter is reserved for future use. It must be NULL.

dwAuthError [in, optional]

Specifies why the credential dialog box is needed. A caller can pass this Windows error parameter, returned by another authentication call, to allow the dialog box to accommodate certain errors. For example, if the password expired status code is passed, the dialog box could prompt the user to change the password on the account.

pszUserName [in, out]

A pointer to a null-terminated string that contains the user name for the credentials. If a nonzero-length string is passed, the UserName option of the dialog box is prefilled with the string. In the case of credentials other than UserName/Password, a marshaled format of the credential can be passed in. This string is created by calling CredMarshalCredential.

This function copies the user-supplied name to this buffer, copying a maximum of ulUserNameMaxChars characters. This format can be converted toUserName/Password format by using CredUIParseUsername. A marshaled format can be passed directly to a security support provider (SSP).

If the CREDUI_FLAGS_DO_NOT_PERSIST flag is not specified, the value returned in this parameter is of a form that should not be inspected, printed, or persisted other than passing it to CredUIParseUsername. The subsequent results of CredUIParseUsername can be passed only to a client-side authentication function such asWNetAddConnection or an SSP function.

If no domain or server is specified as part of this parameter, the value of the pszTargetName parameter is used as the domain to form a DomainName\UserName pair. On output, this parameter receives a string that contains that DomainName\UserName pair.

ulUserNameMaxChars [in]

The maximum number of characters that can be copied to pszUserName including the terminating null character.

Note  CREDUI_MAX_USERNAME_LENGTH does not include the terminating null character.

pszPassword [in, out]

A pointer to a null-terminated string that contains the password for the credentials. If a nonzero-length string is specified for pszPassword, the password option of the dialog box will be prefilled with the string.

This function copies the user-supplied password to this buffer, copying a maximum of ulPasswordMaxChars characters. If the CREDUI_FLAGS_DO_NOT_PERSIST flag is not specified, the value returned in this parameter is of a form that should not be inspected, printed, or persisted other than passing it to a client-side authentication function such as WNetAddConnection or an SSP function.

When you have finished using the password, clear the password from memory by calling the SecureZeroMemory function. For more information about protecting passwords, see Handling Passwords.

ulPasswordMaxChars [in]

The maximum number of characters that can be copied to pszPassword including the terminating null character.

Note  CREDUI_MAX_PASSWORD_LENGTH does not include the terminating null character.

pfSave [in, out]

A pointer to a BOOL that specifies the initial state of the Save check box and receives the state of the Save check box after the user has responded to the dialog box. If this value is not NULL and CredUIPromptForCredentials returns NO_ERROR, then pfSave returns the state of the Save check box when the user chose OK in the dialog box.

If the CREDUI_FLAGS_PERSIST flag is specified, the Save check box is not displayed, but is considered to be selected.

If the CREDUI_FLAGS_DO_NOT_PERSIST flag is specified and CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX is not specified, the Save check box is not displayed, but is considered to be cleared.

An application that needs to use CredUI to prompt the user for credentials, but does not need the credential management services provided by the credential manager, can use pfSave to receive the state of the Save check box after the user closes the dialog box. To do this, the caller must specify CREDUI_FLAGS_DO_NOT_PERSIST and CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX in dwFlags. When CREDUI_FLAGS_DO_NOT_PERSIST and CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX are set, the application is responsible for examining *pfSave after the function returns, and if *pfSave is TRUE, then the application must take the appropriate action to save the user credentials within the resources of the application.

dwFlags [in]

DWORD value that specifies special behavior for this function. This value can be a bitwise-OR combination of zero or more of the following values.

Value Meaning
CREDUI_FLAGS_ALWAYS_SHOW_UI 0x00080

Specifies that a user interface will be shown even if the credentials can be returned from an existing credential in credential manager. This flag is permitted only if CREDUI_FLAGS_GENERIC_CREDENTIALS is also specified.

CREDUI_FLAGS_COMPLETE_USERNAME 0x00800

Populate the combo box with the prompt for a user name.

CREDUI_FLAGS_DO_NOT_PERSIST 0x00002

Do not store credentials or display check boxes. You can pass CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX with this flag to display the Save check box only, and the result is returned in the pfSave output parameter.

CREDUI_FLAGS_EXCLUDE_CERTIFICATES 0x00008

Populate the combo box with user name/password only. Do not display certificates or smart cards in the combo box.

CREDUI_FLAGS_EXPECT_CONFIRMATION 0x20000

Specifies that the caller will call CredUIConfirmCredentials after checking to determine whether the returned credentials are actually valid. This mechanism ensures that credentials that are not valid are not saved to the credential manager. Specify this flag in all cases unless CREDUI_FLAGS_DO_NOT_PERSIST is specified.

CREDUI_FLAGS_GENERIC_CREDENTIALS 0x40000

Consider the credentials entered by the user to be generic credentials.

CREDUI_FLAGS_INCORRECT_PASSWORD 0x00001

Notify the user of insufficient credentials by displaying the "Logon unsuccessful" balloon tip.

CREDUI_FLAGS_KEEP_USERNAME 0x10000

Do not allow the user to change the supplied user name.

CREDUI_FLAGS_PASSWORD_ONLY_OK 0x00200

Populate the combo box with the password only. Do not allow a user name to be entered.

CREDUI_FLAGS_PERSIST 0x01000

Do not show the Save check box, but the credential is saved as though the box were shown and selected.

CREDUI_FLAGS_REQUEST_ADMINISTRATOR 0x00004

Populate the combo box with local administrators only.

Windows XP Home Edition:  This flag will filter out the well-known Administrator account.
CREDUI_FLAGS_REQUIRE_CERTIFICATE 0x00010

Populate the combo box with certificates and smart cards only. Do not allow a user name to be entered.

CREDUI_FLAGS_REQUIRE_SMARTCARD 0x00100

Populate the combo box with certificates or smart cards only. Do not allow a user name to be entered.

CREDUI_FLAGS_SERVER_CREDENTIAL )X04000

This flag is meaningful only in locating a matching credential to prefill the dialog box, should authentication fail. When this flag is specified, wildcard credentials will not be matched. It has no effect when writing a credential. CredUI does not create credentials that contain wildcard characters. Any found were either created explicitly by the user or created programmatically, as happens when a RAS connection is made.

CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX 0x00040

If the check box is selected, show the Save check box and return TRUE in the pfSave output parameter, otherwise, return FALSE. Check box uses the value in pfSave by default.

CREDUI_FLAGS_USERNAME_TARGET_CREDENTIALS 0x80000

The credential is a "runas" credential. The TargetName parameter specifies the name of the command or program being run. It is used for prompting purposes only.

CREDUI_FLAGS_VALIDATE_USERNAME 0x00400

Check that the user name is valid.

 

五、 NetGetJoinInformation function

The NetGetJoinInformation function retrieves join status information for the specified computer.

NET_API_STATUS NetGetJoinInformation(
  _In_   LPCWSTR lpServer,
  _Out_  LPWSTR *lpNameBuffer,
  _Out_  PNETSETUP_JOIN_STATUS BufferType
);

Parameters

lpServer [in]

Pointer to a constant string that specifies the DNS or NetBIOS name of the computer on which to call the function. If this parameter is NULL, the local computer is used.

lpNameBuffer [out]

Pointer to the buffer that receives the NetBIOS name of the domain or workgroup to which the computer is joined. This buffer is allocated by the system and must be freed using the NetApiBufferFree function. For more information, see Network Management Function Buffers and Network Management Function Buffer Lengths.

BufferType [out]

Receives the join status of the specified computer. This parameter can have one of the following values.

typedef enum _NETSETUP_JOIN_STATUS {

    NetSetupUnknownStatus = 0,
    NetSetupUnjoined,
    NetSetupWorkgroupName,
    NetSetupDomainName

} NETSETUP_JOIN_STATUS, *PNETSETUP_JOIN_STATUS;




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值