
Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
On Thu, 27 Nov 2003 23:45:04 +0100, Mattias Sjögren wrote:
>>But the .net compiler tells me that I can't assing anything
>>to the left side...
>
> Can you post your code? Are you implementing the interface or are you
> using it to call another object?
Here's my code. I'm trying to implement an object that can be used as a
COM object for a button in IE.
Currently, this doesn't work at all... I have all the entries in the
registry for the button (it works when using an .exe to run instead of the
COM object) and I use regasm to register the dll compiled from the
following code. But the moment I hit the button in IE, it just crashes on
me without showing any of the message boxes from my code.
------------------ cut -------------------------------
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace iebuttontest {
[Guid ("3C7BA736-716C-4346-806D-714778E3F0CD")]
public interface IIEPluginTest1 {
int DoYourJob();
}
public struct OLECMD {
public uint cmdID;
public uint cmdf;
}
[ComImport, Guid("b722bccb-4e68-101b-a2bc-00aa00404770"),
InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleCommandTarget {
void QueryStatus (
ref Guid pguidCmdGroup,
uint cCmds,
[In, Out, MarshalAs(UnmanagedType.LPArray)] OLECMD[] prgCmds,
IntPtr CmdText);
void Exec (
ref Guid pguidCmdGroup,
uint nCmdId,
uint nCmdExecOpt,
ref object pvaIn,
ref object pvaOut);
}
[Guid ("D985E523-358B-4d60-88D8-684474C910F6")]
public class IEPluginTest1 : IIEPluginTest1, IOleCommandTarget
{
public int DoYourJob () {
MessageBox.Show ("Doing my job");
return 0;
}
public void QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[]
prgCmds, IntPtr CmdText) {
MessageBox.Show ("Query status");
/* The following doesn't work because it says I can't assign
to the left hand side.
foreach (OLECMD cmd in prgCmds) {
cmd.cmdf = 3;
}
*/
}
public void Exec(ref Guid pguidCmdGroup, uint nCmdId, uint nCmdExecOpt,
ref object pvaIn, ref object pvaOut) {
MessageBox.Show ("Execing");
}
}
}
------------------ cut -------------------------------
Oliver Sturm

Signature
omnibus ex nihilo ducendis sufficit unum
Jabber sturm@amessage.de ICQ 27142619 MSN macnapple@hotmail.com Y! macnapple