Desktop Search IDL with C#

G

Guest

I'm trying to use the IDL that's part of the Desktop search API in my C#
application. I'm having problems getting things to work. Can anyone point
me in the right direction for using IDL files with C#?

The other problem is I tried including it in a basic C++ app using the 2005
express edition beta 2 and it won't compile the idl saying that there are 2
library blocks. The idl can be found on the desktop search developer page.

http://addins.msn.com/devguide.aspx#WindowsDesktopSearchApi

Thanks for any help.
 
M

Mattias Sjögren

Ben,
I'm trying to use the IDL that's part of the Desktop search API in my C#
application. I'm having problems getting things to work. Can anyone point
me in the right direction for using IDL files with C#?

Try adding a reference to the ADO primary interop assembly, then try
these declarations

[ComImport, Guid("A227843C-1D92-48bc-AED6-DCA566F1790E"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface ISearchDesktop
{
Recordset ExecuteSQLQuery(
[MarshalAs(UnmanagedType.LPWStr)] string lpcwstrSQL);

Recordset ExecuteQuery(
[MarshalAs(UnmanagedType.LPWStr)] string lpcwstrQuery,
[MarshalAs(UnmanagedType.LPWStr)] string
lpcwstrColumn,
[MarshalAs(UnmanagedType.LPWStr)] string lpcwstrSort,
[MarshalAs(UnmanagedType.LPWStr)] string
lpcwstrRestriction);
}


[ComImport, Guid("1AD68C99-00FB-416d-804B-C38DEE75D55E")]
class SearchDesktop {}

The other problem is I tried including it in a basic C++ app using the 2005
express edition beta 2 and it won't compile the idl saying that there are 2
library blocks.

You can just comment out one of them.



Mattias
 
G

Guest

Thanks for your help, but I must say I'm still pretty clueless about using
idl files. Would you know of any good resources to get myself started? I'm
not sure how to use the declarations you gave.

Mattias Sjögren said:
Ben,
I'm trying to use the IDL that's part of the Desktop search API in my C#
application. I'm having problems getting things to work. Can anyone point
me in the right direction for using IDL files with C#?

Try adding a reference to the ADO primary interop assembly, then try
these declarations

[ComImport, Guid("A227843C-1D92-48bc-AED6-DCA566F1790E"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface ISearchDesktop
{
Recordset ExecuteSQLQuery(
[MarshalAs(UnmanagedType.LPWStr)] string lpcwstrSQL);

Recordset ExecuteQuery(
[MarshalAs(UnmanagedType.LPWStr)] string lpcwstrQuery,
[MarshalAs(UnmanagedType.LPWStr)] string
lpcwstrColumn,
[MarshalAs(UnmanagedType.LPWStr)] string lpcwstrSort,
[MarshalAs(UnmanagedType.LPWStr)] string
lpcwstrRestriction);
}


[ComImport, Guid("1AD68C99-00FB-416d-804B-C38DEE75D55E")]
class SearchDesktop {}

The other problem is I tried including it in a basic C++ app using the 2005
express edition beta 2 and it won't compile the idl saying that there are 2
library blocks.

You can just comment out one of them.



Mattias
 
W

Willy Denoyette [MVP]

IDL is a C++ only thing, you can't use IDL files in C#, you have to hand
code the interface definitions (that's what Mattias did) or you have to
import a typelib definition file. Such typelib can be built from a IDL file
using the MIDL compiler (see midl.exe /? for options), of course you need to
start from a correct idl file, the one you are using is "wrong" as it
contains multiple library definitions, you can try to remove one of them and
run midl.exe to generate the typelib. Once you have the tlb file you can try
to set a reference to it in VS.
Note that this Desktop search stuff is still in beta and is primarily meant
to be used from C++, if you don't have a good understanding of COM and C++,
you'll have a hard time to get things right.
Willy.

Ben Phipps said:
Thanks for your help, but I must say I'm still pretty clueless about using
idl files. Would you know of any good resources to get myself started?
I'm
not sure how to use the declarations you gave.

Mattias Sjögren said:
Ben,
I'm trying to use the IDL that's part of the Desktop search API in my C#
application. I'm having problems getting things to work. Can anyone
point
me in the right direction for using IDL files with C#?

Try adding a reference to the ADO primary interop assembly, then try
these declarations

[ComImport, Guid("A227843C-1D92-48bc-AED6-DCA566F1790E"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface ISearchDesktop
{
Recordset ExecuteSQLQuery(
[MarshalAs(UnmanagedType.LPWStr)] string lpcwstrSQL);

Recordset ExecuteQuery(
[MarshalAs(UnmanagedType.LPWStr)] string lpcwstrQuery,
[MarshalAs(UnmanagedType.LPWStr)] string
lpcwstrColumn,
[MarshalAs(UnmanagedType.LPWStr)] string lpcwstrSort,
[MarshalAs(UnmanagedType.LPWStr)] string
lpcwstrRestriction);
}


[ComImport, Guid("1AD68C99-00FB-416d-804B-C38DEE75D55E")]
class SearchDesktop {}

The other problem is I tried including it in a basic C++ app using the
2005
express edition beta 2 and it won't compile the idl saying that there
are 2
library blocks.

You can just comment out one of them.



Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top