java - 使用 Java Jacob 库设置 MaxRecords

标签 java jacob windows-search

我正在尝试使用 java Jacob library. 来使用 Windows 搜索但我无法指定 maxRecords限制返回行数的选项。

我正在尝试使用这一行来做到这一点:

Dispatch.put(connection, "MaxRecords", new Variant(10));

设置连接后:

connection = new Dispatch("ADODB.Connection");
Dispatch.call(connection, "Open", "Provider=Search.CollatorDSO;Extended Properties='Application=Windows';");

//-------> error in the following line  <-------
Dispatch.put(connection, "MaxRecords", new Variant(10));

results = Dispatch.call(connection, "Execute",
        "SELECT System.ItemName, System.DateModified " +
        "FROM SystemIndex " +
        "WHERE Directory='file:C:/my/folder/path' AND Contains('a')").toDispatch();

while (!Dispatch.get(results, "EOF").getBoolean()) {
        Dispatch fields = Dispatch.get(results, "Fields").toDispatch();
        String filename = Dispatch.get(Dispatch.call(fields, "Item", new Integer(0)).toDispatch(), "Value").toString();
        String filedate = Dispatch.get(Dispatch.call(fields, "Item", new Integer(1)).toDispatch(), "Value").toString();
        list.put(filename, filedate);
        Dispatch.call(results, "MoveNext");
}

我做错了什么? 编译时没有错误,但执行时我收到此消息:

com.jacob.com.ComFailException: A COM exception has been encountered:
At Invoke of: MaxRecords
Description: 80020007 / No named arguments.
...
Internal Server Error (500) - The server encountered an unexpected condition which prevented it from fulfilling the request

通过 URL 访问我的 Restful 时的这个:

Internal Server Error

The server encountered an unexpected condition which prevented it from fulfilling the request You can get technical details here. Please continue your visit at our home page.

没有那条线一切正常。

最佳答案

根据文档,Connection对象没有 MaxRecords 属性。我想你想在RecordSet上设置MaxRecords对象。

编辑:

我还没有尝试过这些,但会尝试以下方式:

connection = new Dispatch("ADODB.Connection");
Dispatch.call(connection, "Open", "Provider=Search.CollatorDSO;Extended Properties='Application=Windows';");

String sql = "SELECT System.ItemName, System.DateModified " +
    "FROM SystemIndex " +
    "WHERE Directory='file:C:/my/folder/path' AND Contains('a')"

recordSet = new Dispatch("ADODB.Recordset");
Dispatch.put(recordSet, "MaxRecords", new Variant(10));

Dispatch.call(recordSet, "Open", sql, connection);

while (!Dispatch.get(recordSet, "EOF").getBoolean()) {
    ...
}

关于java - 使用 Java Jacob 库设置 MaxRecords,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21754688/

相关文章:

java - 想要使用 Jacob jar 从 Outlook 断开连接或删除 PST

java - 使用 JACOB (Java) 保存 Word 文档

java - Android 应用程序不会将数据存储在数据库中

java - 为什么 LocalBroadCastManager 从 IntentService 发送的 Intent 没有被 Activity 类中的 BroadCastReceiver 接收到?

java - 如何将鼠标监听器添加到 JPanel 图像?

java - 如何使用 Jacob 从 Java 代码中禁用 VB6 MsgBox

windows - 如何为 Windows 资源管理器搜索 UI 编写自定义搜索提供程序

c# - Windows 搜索查询文件内容中单词/子字符串的*部分*

vb.net - 如何在 Visual Basic 应用程序中打开 "Windows Search"?

java - TreeMap lastKey 查找时间