IQueryInfo driving me insane

R

rose.kevin

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
 
P

Patrick Steele

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).
 

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