我想通过Windows搜索索引服务读取DWG / AutoCAD文件的元数据。我正在谈论可以在没有打开AutoCAD的资源管理器中右键单击的属性。

我有一个基于MFC对话的基于MFC对话的应用程序,在Visual C ++ 2005中编写,来自此应用程序,我想访问给定文件的元数据(如作者,创建日期等)。这是由ifilter完成的,但自Windows XP以来已弃用,并且在Windows 8中将消失(并且Loadifilter不存在VS2005)。现在从我理解的是,它可以用Windows搜索完成 - 如果我错了,请纠正我。我发现的每个示例(包括MSDN)都显示了如何向Windows搜索有关您自己的文件的数据,但是虽然。我需要的是知道如何向Windows搜索给定文件的元数据。

谢谢 t.g.wilk

编辑: 这是我到目前为止提出的东西:

BOOL WSQ_DoQuery( const wchar_t *constr, const wchar_t *querystr, VARIANT &result ) {

    HRESULT hr = 0;

    BOOL ret;
    // Get the ADO connection
    _Connection *con = NULL;
    hr = CoCreateInstance( CLSID_Connection, NULL, CLSCTX_ALL, IID__Connection, (LPVOID *)&con );
    if ( SUCCEEDED(hr) ) {

        _Recordset *rs = NULL;

        // Convert wide strings to BSTR as required by ADO APIs
        BSTR bconstr = SysAllocString( constr );
        BSTR bquerystr = SysAllocString( querystr );

        if ( bconstr && bquerystr ) {

            // Open the connection
            hr = con->Open( bconstr, NULL, NULL, 0 );
            if ( SUCCEEDED(hr) ) {

                // Execute the query
                hr = con->Execute( bquerystr, NULL, 0, &rs );
                if ( SUCCEEDED(hr) ) {

                    // Display the results
                    ret = WSQ_GetCDate( rs ,result);
                    rs->Release();

                } else {
                    TRACE( "Failed to execute query, %08x\r\n", hr );
                }   // if
            } else {
                TRACE( "Failed to open ADO connection, %08x\r\n", hr );
            }   // if

        } else {
            TRACE("Failed to convert wide to BSTR\r\n" );
        }   // if

        con->Release();
        if ( bconstr ) {
            SysFreeString( bconstr );
        }
        if ( bquerystr ) {
            SysFreeString( bquerystr );
        }
    } else {
        TRACE("Failed to get connection, %08x\r\n", hr );
    }   // if
    return ret;
}   // DoQuery
.

连接字符串(约束)为

provider=Search.CollatorDSO.1;EXTENDED PROPERTIES="Application=Windows"
.

由iSearchQueryHelper返回。 并且查询(querystr)是

SELECT System.Document.DateCreated FROM SystemIndex WHERE System.FileName LIKE 'filename%' AND DIRECTORY='file:C:\path\to\file'
.

现在问题是我收到例外:

First-chance exception at 0x77c5fc56 in fraudTest.exe: Microsoft C++ exception: CNLBaseException at memory location 0x0012d6d0..
. 在此行上

hr = con->Open( bconstr, NULL, NULL, 0 );
.

后跟查询的空结果(此代码来自wsq_getcdate):

rs->get_EOF( &eor );
while ( eor != VARIANT_TRUE ) { //this never executes }
.

在异常之后出现假冒SUCCEEDED(hr)返回true。 我在哪里做出错误,如何尝试找到它?

谢谢 t.g.wilk

有帮助吗?

解决方案

我没有解决这个特殊问题,但我了解到我不需要Windows搜索来获取文件元数据。要查找的关键字是“属性”而不是元数据。我从Windows SDK v7.0示例应用程序中获取了我的代码名为propertyEdit。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top