M
Milos
Hello,
I need to create a IE Extension in C#. I want to add a button to IE standard
toolbar and then make IE call the DLL when button is clicked.
I have started with the following code
-------------------------------- code --------------------------------
[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode)]
public struct OLECMDTEXT
{
public uint cmdtextf;
public uint cwActual;
public uint cwBuf;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=100)]public char rgwz;
}
[StructLayout(LayoutKind.Sequential)]
public struct OLECMD
{
public uint cmdID;
public uint cmdf;
}
[ComImport,
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleCommandTarget
{
void QueryStatus(ref Guid pguidCmdGroup, UInt32 cCmds,
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex=1)]
OLECMD[] prgCmds, ref OLECMDTEXT CmdText);
void Exec(ref Guid pguidCmdGroup, uint nCmdId, uint nCmdExecOpt,
ref object pvaIn, ref object pvaOut);
}
[ClassInterface(ClassInterfaceType.None),
ComSourceInterfaces(typeof(COM_Events))]
public class COMAddin: IOleCommandTarget
{
// ....
public void QueryStatus(ref Guid pguidCmdGroup,
UInt32 cCmds, OLECMD[] prgCmds, ref OLECMDTEXT CmdText)
{
// ....
}
public void Exec(ref Guid pguidCmdGroup, uint nCmdId,
uint nCmdExecOpt, ref object pvaIn, ref object pvaOut)
{
// .... I would add here OnClick actions
}
}
---------------------------- end code --------------------------------
But I don't know what to do next.
I know that I have to add a key in
HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Extensions.
And I have to somehow register the COM DLL, and create some GUIDs. But this
is a managed DLL, and all articles that I find on the net are related to
plain native C++. And I need to get the IE Document data somehow
(IHTMLDocument2 or something?)
Can anyone point me to a good article for this, or help me directly?
Thank you in advance,
Milos
I need to create a IE Extension in C#. I want to add a button to IE standard
toolbar and then make IE call the DLL when button is clicked.
I have started with the following code
-------------------------------- code --------------------------------
[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode)]
public struct OLECMDTEXT
{
public uint cmdtextf;
public uint cwActual;
public uint cwBuf;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=100)]public char rgwz;
}
[StructLayout(LayoutKind.Sequential)]
public struct OLECMD
{
public uint cmdID;
public uint cmdf;
}
[ComImport,
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleCommandTarget
{
void QueryStatus(ref Guid pguidCmdGroup, UInt32 cCmds,
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex=1)]
OLECMD[] prgCmds, ref OLECMDTEXT CmdText);
void Exec(ref Guid pguidCmdGroup, uint nCmdId, uint nCmdExecOpt,
ref object pvaIn, ref object pvaOut);
}
[ClassInterface(ClassInterfaceType.None),
ComSourceInterfaces(typeof(COM_Events))]
public class COMAddin: IOleCommandTarget
{
// ....
public void QueryStatus(ref Guid pguidCmdGroup,
UInt32 cCmds, OLECMD[] prgCmds, ref OLECMDTEXT CmdText)
{
// ....
}
public void Exec(ref Guid pguidCmdGroup, uint nCmdId,
uint nCmdExecOpt, ref object pvaIn, ref object pvaOut)
{
// .... I would add here OnClick actions
}
}
---------------------------- end code --------------------------------
But I don't know what to do next.
I know that I have to add a key in
HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Extensions.
And I have to somehow register the COM DLL, and create some GUIDs. But this
is a managed DLL, and all articles that I find on the net are related to
plain native C++. And I need to get the IE Document data somehow
(IHTMLDocument2 or something?)
Can anyone point me to a good article for this, or help me directly?
Thank you in advance,
Milos