
Use P/Invoke with Ease #62
Chapter 7, Help and Research
|
239
HACK
to the following:
Dim url As String = _
String.Format("http://groups.google.com/groups?q={0}", _
System.Web.HttpUtility.UrlEncode(selectedText))
As you can see from this example, it would be very simple to change this to
any online resource that has a predictable query string format.
Thanks to Marty Garins for writing this macro and posting it on his web log,
which can be found http://www.little-garins.com/Blogs/marty.
HACK
#62
Use P/Invoke with Ease Hack #62
P/Invoke can be extremely tricky. With the help of a wiki and an add-in, you
can make it as easy as a cut and paste.
The .NET Framework includes a large amount of functionality, but it does not
include everything. For a lot of different functions, you will find yourself using
something called P/Invoke, which is short for platform invoke. P/Invoke
allows you to call Win32 or other unmanaged APIs from your managed code,
but it is not the easiest thing to do. To make a P/Invoke call, you need to cre-
ate the correct signature, invoke the method, and hope that all goes well.
Because you are working with an unmanaged API, this process is much more
susceptible to error. This is where PInvoke.NET comes into play.
Figure 7-13. Google help