471,582 Members | 1,434 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,582 software developers and data experts.

Desktop Search IDL with C#

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#...sktopSearchApi

Thanks for any help.
Nov 17 '05 #1
3 3226
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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 17 '05 #2
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" wrote:
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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 17 '05 #3
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" <Be*******@discussions.microsoft.com> wrote in message
news:D2**********************************@microsof t.com...
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" wrote:
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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Michael D. Murphy | last post: by
15 posts views Thread by Mephisto187 | last post: by
5 posts views Thread by Terry Olsen | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
1 post views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.