471,594 Members | 2,301 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

IQueryInfo driving me insane

Hi

I am trying to make a little tool tip box pop up when you hover the
mouse over one of our custom filetypes in Windows explorer. And it is
slowly driving me insane.

I have a created a dll, with this as the code:

using System;
using System.IO;
using System.Runtime.InteropServices;
using Microsoft.Win32;

[ComImport(), Guid("0000010B-0000-0000-C000-000000000046"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown )]
public interface IPersistFile
{
[PreserveSig]
uint GetClassID(out Guid pClassID);

[PreserveSig]
uint IsDirty();

[PreserveSig]
uint Load([In, MarshalAs(UnmanagedType.LPWStr)] string pszFileName,
[In] uint dwMode);

[PreserveSig]
uint Save([In, MarshalAs(UnmanagedType.LPWStr)] string pszFileName,
[In] bool fRemember);

[PreserveSig]
uint SaveCompleted([In, MarshalAs(UnmanagedType.LPWStr)] string
pszFileName);

[PreserveSig]
uint GetCurFile([MarshalAs(UnmanagedType.LPWStr)] out string
ppszFileName);
}

[ComImport(), Guid("00021500-0000-0000-C000-000000000046"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown )]
public interface IQueryInfo
{
[PreserveSig]
uint GetInfoTip(uint dwFlags, out IntPtr pszInfoTip);

[PreserveSig]
uint GetInfoFlags(out uint dwFlags);
}

[ComVisible(true), Guid("A2C92C9B-55C8-4d6a-A56E-A7047072F26E")]
public class MyShellInfoClass : IPersistFile, IQueryInfo
{
private const uint E_NOTIMPL = 0x80004001;
private const uint S_OK = 0;
private const uint QITIPF_DEFAULT = 0;
private string tip = string.Empty;

public uint GetInfoFlags(out uint dwFlags)
{
StreamWriter batWriter = File.CreateText("c:/
hamsterWillRuleTheWorld.txt"); batWriter.WriteLine("Hamsters will rule
the world"); batWriter.Close();
dwFlags = QITIPF_DEFAULT;
return S_OK;
}

public uint GetInfoTip(uint dwFlags, out IntPtr pszInfoTip)
{
StreamWriter batWriter = File.CreateText("c:/
hamsterWillRuleTheWorld.txt"); batWriter.WriteLine("Hamsters will rule
the world"); batWriter.Close();
// after calling Load, the shell calls this
// method to get the actual info
pszInfoTip = Marshal.StringToCoTaskMemUni(tip);
return S_OK;
}

public uint IsDirty()
{
StreamWriter batWriter = File.CreateText("c:/
hamsterWillRuleTheWorld.txt"); batWriter.WriteLine("Hamsters will rule
the world"); batWriter.Close();
return E_NOTIMPL;
}

public uint Load(string pszFileName, uint dwMode)
{
StreamWriter batWriter = File.CreateText("c:/
hamsterWillRuleTheWorld.txt"); batWriter.WriteLine("Hamsters will rule
the world"); batWriter.Close();
// shell calls this method when it needs info
// for a particular file. This tells your
// component which file you need to process.
tip = "You are hovering over: " + pszFileName;
return S_OK;
}

public uint Save(string pszFileName, bool fRemember)
{
StreamWriter batWriter = File.CreateText("c:/
hamsterWillRuleTheWorld.txt"); batWriter.WriteLine("Hamsters will rule
the world"); batWriter.Close();
return E_NOTIMPL;
}

public uint SaveCompleted(string pszFileName)
{
StreamWriter batWriter = File.CreateText("c:/
hamsterWillRuleTheWorld.txt"); batWriter.WriteLine("Hamsters will rule
the world"); batWriter.Close();
return E_NOTIMPL;
}

public uint GetCurFile(out string ppszFileName)
{
StreamWriter batWriter = File.CreateText("c:/
hamsterWillRuleTheWorld.txt"); batWriter.WriteLine("Hamsters will rule
the world"); batWriter.Close();
ppszFileName = null;
return E_NOTIMPL;
}

public uint GetClassID(out Guid pClassID)
{
StreamWriter batWriter = File.CreateText("c:/
hamsterWillRuleTheWorld.txt"); batWriter.WriteLine("Hamsters will rule
the world"); batWriter.Close();
pClassID = Guid.Empty;
return E_NOTIMPL;
}
}

I have added the following to the registry:

HKEY_CLASSES_ROOT\.wibble\shellex\{00021500-0000-0000-
C000-000000000046}\{a2c92c9b-55c8-4d6a-a56e-a7047072f26e}

I've copied the built dll to C:\windows\assembly

And I've run:

regasm MyShellInfoClass.dll

But as far as I can tell none of my functions are ever getting called :
( I've tried everything I can think of and it is about to drive me
insane. Please, someone, help me....

Kevin

Feb 12 '07 #1
1 1931
In article <11**********************@h3g2000cwc.googlegroups. com>,
ro********@gmail.com says...
I've copied the built dll to C:\windows\assembly

And I've run:

regasm MyShellInfoClass.dll

But as far as I can tell none of my functions are ever getting called :
( I've tried everything I can think of and it is about to drive me
insane. Please, someone, help me....
I would try giving it a strong name and adding it to the GAC (global
assembly cache).

--
Patrick Steele
http://weblogs.asp.net/psteele
Feb 14 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Chris | last post: by
2 posts views Thread by Grey Knight | last post: by
12 posts views Thread by Marty | last post: by
2 posts views Thread by ipmccun | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | 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.