大网数据广告活动
域与目录服务

Using the SetSearchPreference Method

· 52CE 我爱测

Calling the IDirectorySearch SetSearchPreference method changes the way in which the search results are obtained and presented through the IDirectorySearch interface.

Calling the IDirectorySearch::SetSearchPreference method changes the way in which the search results are obtained and presented through the IDirectorySearch interface.

The SDK documentation defines SetSearchPreference as follows:

HRESULT SetSearchPreference(
            //Search preferences to be set.
            PADS_SEARCHPREF_INFO pSearchPrefs,
            //Number of preferences.
            DWORD dwNumPrefs
            );

Multiple preferences may be set by passing an array as the first parameter and the array size as the second parameter.

ADS_SEARCHPREF_INFO arSearchPrefs[2];
 
arSearchPrefs[0].dwSearchPref = ADS_SEARCHPREF_PAGESIZE; 
arSearchPrefs[0].vValue.dwType = ADSTYPE_INTEGER;
arSearchPrefs[0].vValue.Integer = 100;
 
arSearchPrefs[1].dwSearchPref = ADS_SEARCHPREF_SEARCH_SCOPE; 
arSearchPrefs[1].vValue.dwType = ADSTYPE_INTEGER; 
arSearchPrefs[1].vValue.Integer = ADS_SCOPE_SUBTREE; 
 
hr = pDSearch->SetSearchPreference(&arSearchPrefs, 2);

This example sets the page size to 100 rows and the scope to the ADS_SCOPE_SUBTREE type. The page size setting causes the server to immediately return data to the client, after 100 rows have been calculated. The ADS_SCOPE_SUBTREE setting causes the search to encompass all branches in the tree below the point from which the search is being executed.

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。