473,379 Members | 1,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Internet Explorer Extension (COM)

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
Nov 17 '05 #1
1 3750
Hi,
In project properties/ Configuration Properties you have a "register for
COM Interop" set it.
Then you can decorate your class with Guid and/or ClassInterface
attributes.

For the registry you can use the classes provided by the framework.

I do not know how to make a COM be accesible to IE, but if you have some C
or VB code the above may hepl you.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Milos" <th******@troop.com> wrote in message
news:29******************************@ureader.com. ..
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

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: ASD | last post by:
Hi Is this doable: I have a shortcut on my desctop that points to web location. When a user clicks on it the Internet explorer opens the web location but without the navigation bar...
2
by: Jason Keirstead | last post by:
Is there a way I can add a setter/getter to the HTMLElement prototype in internet explorer? This, for example, works fine in Mozilla: HTMLElement.prototype.__defineSetter__("foobar", function...
4
by: Nicolás Castagnet | last post by:
Hi, I write this post because I notice a strange behavior related with "Temporary Internet Files" and maybe some of you can help me to understand it. I am working in a web application with...
3
by: benji | last post by:
How can I set up my IE to view files with extension .aspx ?
2
by: Matt | last post by:
Hey Folks, We discovered an interesting behavior last week and after failing to find anything in the Knowledgebase or MSDN, I thought I would ping the community. We are in the process of...
3
by: VK | last post by:
Internet Explorer 7 beta 2 preview CNET Editor review: <http://reviews.cnet.com/Internet_Explorer_7_for_XP_SP2_Beta_2/4505-3514_7-31454661-2.html?tag=nl.e415> Summary (my personal review...
7
by: Danny | last post by:
Hello: I would like to develop a browser extension, or whatever such a thing is classified as, that would allow a user of IE6, and possibly IE7, to switch between a live and development page. ...
2
by: David Lozzi | last post by:
Howdy, I have a simple file uploader in a form, and I take the image and check for the file extension. Now I when upload a jpg image in FireFox the content type is image/jpeg. When I upload the...
26
by: Prisoner at War | last post by:
Hi, All: I have a JavaScript search engine that always causes MSIE 7 to do a top-of-page security "warning" (that top-of-page-bar, and not an "alert" )...but other websites' JavaScripts do not...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.