I want to use Windows Search from java.
I checked out the master branch 1e690b80, built the project (unit tests crash JVM) and copied the jars args4j-2.0.8.jar, com4j-2.2-SNAPSHOT.jar,tlbimp-2.2-SNAPSHOT.jar to my lib/
Then I generated the java classes (there were some warnings):
package org.useindexer;
public class Main {
public static void main(final String[] args) {
final ISearchManager searchManager = ClassFactory.createCSearchManager();
final ISearchCatalogManager searchCatalogManager = searchManager.getCatalog("SystemIndex");
final ISearchQueryHelper queryHelper = searchCatalogManager.getQueryHelper();
final String connectionString = queryHelper.connectionString();
}
}
Calling the getter connectionString() fails with:
Exception in thread "main" com4j.ComException: unexpected conversion type: 2 : .\invoke.cpp:470
at com4j.Wrapper.invoke(Wrapper.java:187)
at com.sun.proxy.$Proxy7.connectionString(Unknown Source)
at org.useindexer.Main.main(Main.java:9)
Caused by: com4j.ComException: unexpected conversion type: 2 : .\invoke.cpp:470
at com4j.Native.invoke(Native Method)
at com4j.StandardComMethod.invoke(StandardComMethod.java:35)
at com4j.Wrapper$InvocationThunk.call(Wrapper.java:356)
at com4j.Task.invoke(Task.java:50)
at com4j.ComThread.run0(ComThread.java:172)
at com4j.ComThread.run(ComThread.java:153)
Running OutByteBufTest
Hello, World!
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 sec
Running VariantTest
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffc35854dbd, pid=8788, tid=0x0000000000001318
#
# JRE version: OpenJDK Runtime Environment (8.0_181-b13) (build 1.8.0_181-1-ojdkbuild-b13)
# Java VM: OpenJDK 64-Bit Server VM (25.181-b13 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C [OLEAUT32.dll+0x94dbd]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\haltura\com4j\test\hs_err_pid8788.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Results :
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0
tlbimp output:
C:\haltura\indexer\useindexer>java -jar ./lib/tlbimp-2.2-SNAPSHOT.jar -o ./src -p org.useindexer "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\um\x64\SearchAPI.tlb"
Generating definitions from SearchAPILib
Unable to handle the type tag_inner_PROPVARIANT
method GetParameter
interface ISearchCatalogManager
Unable to handle the type tag_inner_PROPVARIANT
method SetParameter
interface ISearchCatalogManager
Unable to handle the type _ULARGE_INTEGER
method RemoteSeek
interface IStream
Unable to handle the type _ULARGE_INTEGER
method SetSize
interface IStream
Unable to handle the type _ULARGE_INTEGER
method RemoteCopyTo
interface IStream
Unable to handle the type _ULARGE_INTEGER
method LockRegion
interface IStream
Unable to handle the type _ULARGE_INTEGER
method UnlockRegion
interface IStream
Unable to handle the type tagSTATSTG
method Stat
interface IStream
Unable to handle the type tagRemSNB
method OpenStorage
interface IStorage
Unable to handle the type tagRemSNB
method RemoteCopyTo
interface IStorage
Unable to handle the type _FILETIME
method SetElementTimes
interface IStorage
Unable to handle the type tagSTATSTG
method Stat
interface IStorage
Unable to handle the type tagSTATSTG
method RemoteNext
interface IEnumSTATSTG
Unable to handle the type tagTYPEATTR
method RemoteGetTypeAttr
interface ITypeInfo
Unable to handle the type tagFUNCDESC
method RemoteGetFuncDesc
interface ITypeInfo
Unable to handle the type tagVARDESC
method RemoteGetVarDesc
interface ITypeInfo
Unable to handle the type tagFUNCDESC
method RemoteBind
interface ITypeComp
Unable to handle the type tagTLIBATTR
method RemoteGetLibAttr
interface ITypeLib
Unable to handle the type _SEARCH_ITEM_PERSISTENT_CHANGE
method OnItemsChanged
interface ISearchPersistentItemsChangedSink
Unable to handle the type _SEARCH_ITEM_CHANGE
method OnChange
interface ISearchViewChangedSink
Unable to handle the type _SEARCH_ITEM_INDEXING_STATUS
method OnItemIndexedStatusChange
interface ISearchNotifyInlineSite
Unable to handle the type LPWSTR*
method RemoteNext
interface IEnumString
Unable to handle the type _tagpropertykey
method WriteProperties
interface ISearchQueryHelper
Unable to handle the type _SEARCH_ITEM_CHANGE
method OnItemsChanged
interface ISearchItemsChangedSink
Unable to handle the type tag_inner_PROPVARIANT
method GetParameter
interface ISearchManager
Unable to handle the type tag_inner_PROPVARIANT
method SetParameter
interface ISearchManager
Unable to handle the type _FILTERED_DATA_SOURCES
method LoadIFilter
interface ILoadFilter
Unable to handle the type ushort**
method LoadIFilterFromStorage
interface ILoadFilter
Unable to handle the type _FILTERED_DATA_SOURCES
method LoadIFilterFromStream
interface ILoadFilter
Unable to handle the type tagFULLPROPSPEC
method Init
interface IFilter
Unable to handle the type tagSTAT_CHUNK
method GetChunk
interface IFilter
Unable to handle the type tag_inner_PROPVARIANT
method GetValue
interface IFilter
Unable to handle the type tagFILTERREGION
method BindRegion
interface IFilter
Unable to handle the type _FILTERED_DATA_SOURCES
method LoadIFilterWithPrivateComActivation
interface ILoadFilterWithPrivateComActivation
I want to use Windows Search from java. I checked out the master branch 1e690b80, built the project (unit tests crash JVM) and copied the jars args4j-2.0.8.jar, com4j-2.2-SNAPSHOT.jar,tlbimp-2.2-SNAPSHOT.jar to my lib/
Then I generated the java classes (there were some warnings):
and created the Main class:
Calling the getter
connectionString()
fails with:Here's the generated getter:
P.S.
mvn package
:tlbimp output: