How to create events in COM interop(in c#)

This is my COM wrapper written in c#.

using System.Runtime.InteropServices;
namespace  SAFE_NAMESPACE_NAME
{
 #region Events raised by your COM class
 public delegate void Event1Handler(int i, int j);
 [Guid("C37B4CE2-E6F0-404b-836A-722064BADBF1"),
 InterfaceType(ComInterfaceType.InterfaceIsIDispatch) ]
 public interface EVENTS_NAME
 {
  // TODO: Insert event handlers for events your class raises here.
  [DispId(1)] void Event1(int i, int j);
 }
 #endregion
 #region Interface published by your COM class
 [Guid("117E0536-B80A-45b5-92BA-81B7AF5BAE5E"),
 InterfaceType(ComInterfaceType.InterfaceIsDual) ]
 public interface INTERFACE_NAME
 {
  // TODO: Insert functions your class publishes here.
  [DispId(1)] int Function1(string s1, string s2);
 }
 #endregion
 [Guid("251A0F17-2118-4884-BC55-4CEF4EA8A009"),
 ProgId("[SAFE_NAMESPACE_NAME].[CLASS_NAME]"),
 ClassInterface(ClassInterfaceType.None),
 ComSourceInterfaces(typeof(EVENTS_NAME)) ]
 public class CLASS_NAME : INTERFACE_NAME
 {
  //
  // TODO: Insert events raised by your class here.
  //

  public event Event1Handler Event;
  public CLASS_NAME() : base()
  {}
  // TODO: Implement the methods of your class interface here.
  public int Function1(string s1, string s2)
  {
   return 0;
  }
 }
}

c++ client
I am able to call the method exposed through interface.
#import "SAFE_NAMESPACE_NAME.tlb"
using namespace SAFE_NAMESPACE_NAME;
INTERFACE_NAME *t_my_interface;

 CoInitialize(NULL);
 SAFE_NAMESPACE_NAME::INTERFACE_NAMEPtr 
q(__uuidof(SAFE_NAMESPACE_NAME::EVENTS_NAME));
 t_my_interface = q;
 t_my_interface->Function1("Hi","Hello");

But how to add Event handler in unmanaged c++ for the above Interface.
Waiting for the raply. 


0
mayur1 (10)
12/1/2006 7:19:19 AM
vc.mfc 33608 articles. 0 followers. Follow

0 Replies
847 Views

Similar Articles

[PageSpeed] 28

Reply:

Similar Artilces:

FileSystemWatcher won't fire for directory events
I trying to be notified when a directory is created, deleted, renamed or moved. What am I doing wrong? moFolderSysWatch = New FileSystemWatcher(m_WatchDirectory, "") moFolderSysWatch.IncludeSubdirectories = True moFolderSysWatch.NotifyFilter = NotifyFilters.DirectoryName moFolderSysWatch.EnableRaisingEvents = True Am 05.03.2010 19:13, schrieb Mike Beebe: > I trying to be notified when a directory is created, deleted, renamed or > moved. What am I doing wrong? > > moFolderSysWatch = New FileSystemWatcher(m_WatchDir...

How do I create a zip file for a folder of e-mail messages
How do I create a zip file for a folder of e-mail messages? don't think you can do that "inside" outlook. outlook folders are not like windows folders. you need to select all the messages, do a "save as" and save them to a windows folder, then zip that "Judi" wrote: > How do I create a zip file for a folder of e-mail messages? you'd need to drag the messages to a folder on the hard drive and zip that folder. -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: http...

Userforms in Excel 2003 created in Excel 2000
I have made a programme in Excel 2000 using VBA and a number of sheets. Indata to the programme is at some instances entered from User forms. The User forms are activated by clicking a Command Buttons. While trying to activate the User forms in Excel 2003, an error message occured: "Compile error in hidden module: Sheet 15". Changing security level to low was not enough. I became aware of that an ActiveCGM Control was missing. After installing the file acgm.dll, the programme was running on computers in my house, but problems still occured on other computers. Are there any other se...

creating a new Service
I use vs2005, and want to create a new Service project. The problem is that I don't want to use C#. I want to use plain old C++, and create a empty template Server project, as I did with VS6.0 . How can I do it? Thanks Dudu Arbel >I use vs2005, and want to create a new Service project. > The problem is that I don't want to use C#. > I want to use plain old C++, and create a empty template Server project, > as > I did with VS6.0 . > > How can I do it? If you install the platform SDK, it contains a sample project for building a service. I've used it a c...

Mailboxes are not created in the exchange servers
we have two Windows 2003 Enterprise DC's. Exchange server 2003 was installed on one of the DC's and it was working fine. We have installed exchange server 2003 on the second DC inorder to transfer all the mail boxes from the first DC (where exchange server was running perfectly) to second DC. Now when we create users it is showing whether to create mail box for the user, but it is not creating mail box on either of the exchange servers. The existing mail boxes on the first DC is working fine. We want all the mailboxes shifted to the second DC and it must be able to work fin...

How to create a new invoive model report in CRM 3.0
I need to personalize my invoice report to my company invoice model. How can i do this. Are those models a standard in Reporting Services or CRM 3 forms. Thanks Arnaud MAilly There is a sample called "quote sample report" posted at http://www.gotdotnet.com/codegallery/codegallery.aspx?id=b6499eb0-0eae-4597-b38e-ee9cbc71a404. Please also read the discussion message at reporting seesion to look for more details. One of my colleague is also going to post a set of sample reports, including an invoice sample report, on that site in about a week. You should get a sample report...

Exchange IMC Event ID 3038
I continue to get Event ID 3038 on my Exchange 5.5 server. it seems to be directly related to "old" users appearing again in my License Manager and messages pile up in my Outbound Messages Awaiting Conversion queue. I found, on your site, the information about deleting/recreating the in and out box, defrag, and recreate the Internet Mail Service. Is this an easy process for someone not very knowledgable about the Exchange Server? what is the process to recreate the IMS? Thanks, Marilyn Simply highlight it and choose delete ( or the X IIRC) from the admin gui menu. To re...

Re: Create Exchange 2007 mailbox 09-10-10
"Kenneth A. Larsen" <LarsenK@verizon.net> wrote in message news:... > > "Kenneth A. Larsen" <LarsenK@verizon.net> wrote in message > news:OB5DivqLLHA.4120@TK2MSFTNGP02.phx.gbl... >> >> "david" <jenesaispas@21c.net> wrote in message news:... >>> Message-ID: <eb2f4fa1080d471baf0ea95fc8f07463@newspe.com> >>> X-Mailer: http://www.umailcampaign.com, ip log:72.10.138.169 >>> Newsgroups: microsoft.public.scripting.vbscript >>> NNTP-Posting-Host: 22.bb.5446.static.theplanet.com 70...

C++ Refactoring tool
Hi, does anyone know of a good C++ refactoring tool? (apparently Visual Studio 2005 contains refactoring functionality for C#, but not for C++). Thanks. http://www.ideat-solutions.com/refpp/ http://www.slickedit.com/ https://sourceforge.net/projects/cpptool/ -- --------------------------------------------------- Automate your software builds with Visual Build Pro http://www.visualbuild.com/ "Patje" <forumpvc@ompartners.com> wrote in message news:1135951759.131382.74280@o13g2000cwo.googlegroups.com... > Hi, > does anyone know of a good C++ refactoring tool? > (ap...

In Excel I want to create a Worksheet menu bar to limit users to .
In Excel I want to create a Worksheet menu bar to limit users, to the options provided by this customized Menu. ...

Mails are not going to hotmail.com
Hi, I have checked our SMTP Virtual Server settings and everything seems fine. We can send mails to other domains but hotmail.com The mails are just pilling up at the queue. I have noted though that mails are coming in from hotmail but sending to that domain is an issue. Reverse DNS lookup tests point to the right FQDN. and we are not blacklisted, can anyone help me on this? We use a cisco pix firewall and run Exchange Server 2003 on Windows Server 2003 OS. -- Buchi what happens if you try to send an email to hotmail via a telnet session from your Exchange server? -- Susan Conkey [...

Event ID 932
I am getting this error. What is causing it? How can I get rid of it? There is now connector with this adress sapce. Received error while processing address space. Examine the connector with this address space and make sure it is legal. If unsure, delete it and recreate via UI. This should ensure it is correct. Address Space = (X500:/o=SMU/ou=SMULA/cn=Recipients) Hr = c0040385 http://groups.google.com/group/microsoft.public.exchange.admin/browse_thread/thread/7ee7058b6149d55b/d463785426512ec9?lnk=st&q=&rnum=1&hl=ru#d463785426512ec9 Nerd wrote: > I am getting this error. W...

Strange "~" file being created!!
Occasionally I have had a "~" file created after working in Outlook Express it has put this file in C:\ on the Desktop down in C:\Documents and Settings\... and on my A: drive when there was a disk present. It is hidden and read- only. Looking at the contents of the file in Notepad it looks suspiciously like a copy of my address book. Everytime I've found one of the these files I've zeroed it out and protected it from further writing, thinking it might be some sort of virus program stealing my address book. Does anyone know what this file is used for, or is anyone ...

Stop hidden window from receiving events temporarily?
Is there a way to stop a hidden window from receiving events while it is displaying a modal dialog? I want to temporarily disable events to a window during this time to avoid my window proc from being recursively invoked. >Is there a way to stop a hidden window from receiving events while it >is displaying a modal dialog? There's no way I know of from stopping a window from receiving messages. >I want to temporarily disable events to >a window during this time to avoid my window proc from being >recursively invoked. Add a flag and test/set/reset it at the appropriate mo...

Sync dataBase with C#
Hi, i've created a clander application (something like outlook's calendar). i want to sync it with my phone (Nokia), the only way i can think of, is to sync my application with Outlook and then my phone with Outlook. is there a way to skip the Outlook sync, and sync my application with the nokia? Thanks, Gidi ...

Cannot create additional address book
I installed Outlook 2003 on Windows XP, and was trying to make my contact list created in a pst file show up in the Address book. In order to do so, I have tried to create Additional Address books through the Tools -> Email accounts screen. However when I select 'Outlook Address book' as the type and click on 'Next' I get the following message "The account you have added is not fully configured. It might not work properly until re-configured correctly." I have reinstalled Outlook 2003 and it doesnt help. Any ideas on how to fix this problem? Vandana Deep <van...

Creating a "tickler file" with Outlook
I am attempring to create a task management system to be administered by one person and used by 10 people. As an overview, our organization wants to make sure managers are not missing financial filing deadlines. We hope to set up the filing dates, notify managers via email as these dates approach, and have the managers email back notification that the task has been completed. I will administer the system and I will need some kind of reporting showing what tasks are complete and which are overdue. I have several ways I can go on this (plus others I have not considered) and I am hoping to find...

create a thematic chart, to show different classes of data
I need to show the same basic data (in my case, journey times), but colour coded or with labels to show different categories (in my eg, to show which journeys can be extended to the City & which require a change of bus). Childishly easy to conceptualise & surely not too difficult to do, but how? The way to do it is to create a series to represent each category. For example, supposing the values to be charted were Name Amt a 24 b 29 c 10 d 45 e 44 f 99 g 66 h 91 i 25 j 60 and you want values <=20 to be red, 21...

How do I create a simple macro
I have an excel spreadsheet that has contact info. The first name in one column i.e. Paul and the last name in another column i.e. Butler and need to create another column that automatically creates a email address for each name i.e. paul.butler@company.com. Then I want to import the excel contact data into Outlook to create a contact list. I'm having a heck of a time. Can someone help me? I'm not sure how you are going to 'automatically create' an email address. If they are all in the format firstname.lastname@company.com and you have the company name then you coul...

Users mailboxes not created when user created
I have a problem that recently just started happening on my exchange 2003 server. When i create a new user account and create the mailbox for exchange, once im done, the mailbox isnt created, adn if you go into the properties of the user account adn go to the exchange email address tab, there isnt an smtp or an x.400 address listed. I am having to manually create and add these, adn then go delete the exchange mailbox and recreate it. This is really annoying and would love to know if anyone has any ideas of how to fix it. Thanks Jason In news:9F836A43-98BF-435A-AA43-AFF10124BE3F@micro...

Create folders and subfolders from Excel
I need to create a set of folders with subfolders from a list in Excel. I can find code to create the folders but not with the subfolders. Any help would be appreciated. Sub New_Folder_And_SubFolder() Dim strNewFolder As String Dim strSubFolder As String strNewFolder = "My New Folder" strSubFolder = "My Sub Folder" MkDir strNewFolder MkDir strNewFolder & "\" & strSubFolder End Sub -- Regards, OssieMac Here is the code I have used so far to make the original foilders and it works perfectly, Option Explicit Dim intRow, objExcel, objShe...

How to change Thai Buddhist to Gregorian calendar when creating apment
I've been trying to create my new appointment using Gregorian Calendar but it seemed that everytime I try to set the recurrence to occur yearly, the carlenday is set to Thai Buddhist Calendar automatically. There's no options for me to choose what type of calenday i want to use. The problem is I cant syncronize this appointment with the BlackBerry. If anyone has any suggestion, pleaseeeee..Thanks in advance -- s_ran4 http://forums.slipstick.com You need to set the Georgian as the default and the Thai as a second calendar index. -- Diane Poremsky [MVP - Outloo...

Worksheet Change Event
I'm looking for an easy way to track changes in a large spreadsheet Could someone help me with code to add a date into column P if any changes are made in the row. The range that this needs to apply to are is A2:N5000 I know this is a worksheet change event but don't understand the mechanics of writing the code to do what I want Hi Karen Try the below which makes use of Worksheet Change and Selection events to track real changes made to the worksheet. Select the sheet tab which you want to work with. Right click the sheet tab and click on 'View Code'. This will...

How do I creat a P-Chart in Excel?
I am in a beginning Stats class and we need to create a P-Chart for one of our assignments in Excel. I am having a very hard time finding how to create the chart in Excel via the help menu. Does anyone know how to create a P-Chart? I have all the data and I do know how to calculate the control points as well as the Mu point. I just need to know if Excel can create the chart and how exactly to do that with the data that I have. Thank you very much Searched Google? Among the many links for "excel p-chart" (w/o the quotes), a promising one was http://www.ngcsu.edu/academi...

Creating uncontrollable windows service
Dear all, I need a code a windows service which can not be controlled by service control manager(like Remote Procedure Call (RPC) where we cannot stop,start and we are not able to change to manual or disabled)... Please guide me Regards Sankar >> I need a code a windows service which can not be controlled by >>service control manager(like Remote Procedure Call (RPC) where we >>cannot stop,start and we are not able to change to manual or >>disabled)... Please guide me Sounds like a dangerous feature to me. If Windows were to allow what you request I think I&#...