How do I expose interfaces from an MFC application.

HI,

I have an existing MFC applicatiion (VC++6.0). Now i need to expose 
Interfaces/methods from this application which c# application can use those 
methods. Could anyone suggest me the steps for this to implement. Also any 
example information would would be more helpful for me.

Thanks in advance.
Karim.
0
karim1 (46)
8/1/2008 4:27:00 AM
vc.mfc 33608 articles. 0 followers. Follow

5 Replies
482 Views

Similar Articles

[PageSpeed] 5

What you would like to do is to add OLE Automation support to your MFC 
application.
Fortunately MFC hides lots of COM complexity associated with OLE Automation.

For more detail, I would suggest to insert "mfc automation" in Google, and 
read some of the result pages...

HTH,
Giovanni



"karim" <karim@discussions.microsoft.com> ha scritto nel messaggio 
news:E57AF567-AEBC-4A72-A69D-4E2A0011A28B@microsoft.com...
> HI,
>
> I have an existing MFC applicatiion (VC++6.0). Now i need to expose
> Interfaces/methods from this application which c# application can use 
> those
> methods. Could anyone suggest me the steps for this to implement. Also any
> example information would would be more helpful for me.
>
> Thanks in advance.
> Karim. 


0
Giovanni
8/1/2008 8:20:10 AM
On Aug 1, 6:27=A0am, karim <ka...@discussions.microsoft.com> wrote:
> HI,
>
> I have an existing MFC applicatiion (VC++6.0). Now i need to expose
> Interfaces/methods from this application which c# application can use tho=
se
> methods. Could anyone suggest me the steps for this to implement. Also an=
y
> example information would would be more helpful for me.
>
> Thanks in advance.
> Karim.

It's best that you expose COM interface to your app. MSDN and Google
will help you finding all the info you may need.

As a general advice... COM is a big subject, so beware. Since you are
only beginning, I'd suggest that you jump straitght to ATL. It's
superior in every way to MFC's COM/Automation support. Mixing the ATL
"approach" and MFC "approach" is a bit involved, but doable and the
payoff in overall functionality is IMO worth it.
0
8/1/2008 8:55:23 AM
This is a very complex task.  I often go as far as to suggst that you build a new project
and add the option to be an automation server, and THEN copy all your code into the new
project (this is often easier than trying to retrofit automation into an existing
project).

There is a massive learning curve on how to do this; for example, do you want a pure COM
interface, an ActiveX interface, or both?  Are you going to support being an embedded
document server or just be an automation target?  Overall, you should be prepared to spend
weeks on learning how to do this.  Unfortunately, the best books on the topic were
published by the now-defunct Wrox Press.
					joe
  
On Thu, 31 Jul 2008 21:27:00 -0700, karim <karim@discussions.microsoft.com> wrote:

>HI,
>
>I have an existing MFC applicatiion (VC++6.0). Now i need to expose 
>Interfaces/methods from this application which c# application can use those 
>methods. Could anyone suggest me the steps for this to implement. Also any 
>example information would would be more helpful for me.
>
>Thanks in advance.
>Karim.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
8/1/2008 1:24:37 PM
If you could update your code to VS 2008 it you could compile it as mixed 
mode (managed and unmanaged parts) and use interop to just call into 
functionality that would call external .NET assemblies that interop to your 
native code.

You may want to pick up a copy of this book if you go down that path:

http://books.google.com/books?id=uhzDXkpEWWoC

Tom

"karim" <karim@discussions.microsoft.com> wrote in message 
news:E57AF567-AEBC-4A72-A69D-4E2A0011A28B@microsoft.com...
> HI,
>
> I have an existing MFC applicatiion (VC++6.0). Now i need to expose
> Interfaces/methods from this application which c# application can use 
> those
> methods. Could anyone suggest me the steps for this to implement. Also any
> example information would would be more helpful for me.
>
> Thanks in advance.
> Karim. 

0
tom.nospam (3240)
8/2/2008 1:20:21 PM
On Aug 1, 12:27=A0am, karim <ka...@discussions.microsoft.com> wrote:
> HI,
>
> I have an existing MFC applicatiion (VC++6.0). Now i need to expose
> Interfaces/methods from this application which c# application can use tho=
se
> methods. Could anyone suggest me the steps for this to implement. Also an=
y
> example information would would be more helpful for me.
>

You shoudl upgrade to any later version of VS and then make your
project a managed one (/clr). This will help you expose your classes
in a .net friendly way to other clients. If you dont want to move up,
then you have no choice but to use COM, which is not easy unless you
are familiar with it.

--
Ajay

0
ajaykalra (6842)
8/4/2008 1:42:04 PM
Reply:

Similar Artilces:

Play divX inside MFC application
Hello, I have to embed a window/form that is a able to play divX video files inside my current MFC application. A first google search on that topic gave several hits like directShow, video control, general directX, CAnimateControl....I'm a little confused now :-( I would be grateful for any hints showing me the right direction to go. Thanks Horst Horst Nabulke wrote: > Hello, > > I have to embed a window/form that is a able to play divX video files > inside my current MFC application. > A first google search on that topic gave several hits like directShow, > video...

Gui interface
Hey guys is it possible to create a GUI that works like a filter. Whic means that i already have a database. I create a gui consisting o radio buttons etc. For example. I select the radio button degree. would then like to display out on excel all the details on degree there r more then 1 detail ) . and so on and so forth for other option like diploma and all.. I really need detailed help here . Thanks for all ur replies -- Message posted from http://www.ExcelForum.com ristanto wrote: > Hey guys is it possible to create a GUI that works like a filter. > Which means that i already h...

MFC and batch files
Greetings, I posted similar topic here few weeks ago. I appreciate the responses. I have succesfully converted a batch file into a MFC dialog based application. Immediate results are a lot faster execution and detailed error reporting. Instead of calling other programs to do the task like a batch file does, I embedded C++ code, MFC and WinAPI functionality to do the same things. However, since this is my first major project, I am certain there is room for improvment by following good software engineering practices. One place where I am encountering trouble is terminating application. S...

How to include a COM in a VC++ application
Hai I have created a com using ATL COM AppWizard. But I am not able to include the COM in a VC++ application. I am able to refer the COM in Visual Basic. So please help me to include the COM in VC++. Regards S.Vinodh Noel (Bangalore) Hi Vinodh The Client code in VC++ referes to ur ATL COm exe using the .h and _i.c files so the client code should be as follows: #include <iostream.h> #include "Server.h" #include "Server_i.c" int main() { ::CoInitialize(NULL); IServerr *pServer; HRESULT hr = ::CoCreateInstance(CLSID_Server,NULL,CLSCTX_INPROC_SERVER,IID_IServ...

Why does MFC call _CrtDumpMemoryLeaks ?!?
(I think this applies to mfc & C++ & debugging, hence the 3 NG) OK, maybe this'll be some kind of rant, but I really don't get it and it would really be nice to know what the rationale behind the "built-in" memory leak detection of MFC is, when any user could provide it on his own without false memory leaks ... Explanation: The Run-Time Library provides for Debug Routines that (among other things) allow reporting of memory-leaks. It is possible to enable *automatic* reporting for the CRT by calling the function _CrtSetDbgFlag(...) with the _CRTDBG_LEAK_CHECK_DF...

MSCRM Application Error Report
Hi, I cannot connect to my CRM servers after using it for 3 weeks. Below is the error from the event viewer: MSCRM Application Error Report -------------------------------------------------------------------------------------------------------- Error Message: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Source File: Line Number: Stack Trace Info: at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain() a...

web form and a running application commuinication
hi, I have a running application on a computer which has a http server, I have some form that can be accessed from a remote computer using http, how can I send messages using these forms to my other application to control it? thanks, Behzad behzad wrote: > hi, > I have a running application on a computer which has a http server, I have > some form that can be accessed from a remote computer using http, how can I > send messages using these forms to my other application to control it? Any way you like. You of course need to use some serverside language (like php or asp) t...

about interface
Hi! Here comes an easy question. Assume a have a class that implements implicitly one or more interfaces. I compile the code and use it and it works good. Now to my question assume that I remove all the interfaces but keep all the method, propery and so on that I used to implement the interfaces. I'm just wondering if I did this would this cause any problem. I mean the purpose of an interface is just a contract that require the class to implement all the members in the interfaces. //Tony On 1/30/2010 6:14 AM, Tony Johansson wrote: > Hi! > > Here comes...

MFC and IP problem
Hello, I have a simple mfc application(exe) and i want to know If it is possible to get back the IP address of a machine which is to connect has my PC by ethernet and to show it in a IP case in my MFC application. Thank you Not very clear what are you talking about. Do you want to know the local IP address? or may be address of different PC in the same LAN? <john.ambou@free.fr> wrote in message news:1144920653.682354.258970@z34g2000cwc.googlegroups.com... > Hello, > > I have a simple mfc application(exe) and i want to know If it is > possible to get back the IP address ...

CRM compatibility with pst archiving applications
Hi there- i know this isn't about the CRM application itself, but i was wondering if anyone has experience of running alongside CRM 3.0 an email archiving application which also archives users' pst's. Specifically Symantec's Enterprise Vault. This system can search for a user's PST's, and archive them away from their pc to central storage. The copy of the pst on the pc is then deleted. The archiving client within Outlook is how the user then accesses the pst content. Would anyone know what effect, if any, this would have on the CRM pst that is created in Outlook? Basica...

From Dexterity, is another application running?
We have communication module that is invoked from a Dexterity command. At the moment, we are using a klunky and not too realistic timer to try to read for a returned file. We'd prefer to add to the robustness of our implementation by having some sort of method which would determine if the app. we opened originally is still running. What's a good way in Dex to figure this out? Thanks for your replies. Herb from Data Tranz, A good way to figure this out in Dex or any development environment is by invoking the winmgmts object. Function IsProcessRunning( strServer, strProcess )...

CRM Web Interface Error
I have just installed CRM 1.2 on an SBS 2003 Premium server. Fully patched, followed all of the documentation I could find. I can add users via the Deployment Manager also, so I know that it works. What I can not do is access it via the web interface. When I try to logon, I get the following message: An error has occurred. For more information, contact your system administrator. I am the adminstrator and have no clue as to where to look. In searching the web, I found a site, SonomaPartners, that lists a private kb article that supposedly addresses this issue The only problem is, I don&#...

Can't find source of Application-defined or object-defined error!?
I won't post all of the code here because it's too extensive but here's a watered down version (all variables declarations are not listed): Dim i as integer Dim PortName As String Dim ReviewSht As String Dim ModelSht As String Dim HoldingsSht As String Dim Model As Range PortName = Right(ActiveSheet.Name, Len(ActiveSheet.Name) - 15) ReviewSht = "Price Weight - " & PortName ModelSht = "Model Data - " & PortName HoldingsSht = "Holdings - " & PortName Application.ScreenUpdating = False With Worksheets(ModelSht).Range("A9") Range...

Importing applicants
Using Integration manager on GP 10, is there any way to import into the employee applicant tables rather than the employee payroll master? Thanks. Jerry No, it's not. There's a tool from eOne Solutions called SmartConnect. It is based on eConnect. If eConnect has a destination object for applicants you're in luck. Otherwise, you'd need to use a different tool. -- Charles Allen, MVP "Jerry Flatto" wrote: > Using Integration manager on GP 10, is there any way to import into the > employee applicant tables rather than the employee payroll master? > ...

how to keep thread safe in MFC dll?
All, I create two threads in MFC extension dll, one is for reading serial communications device in dead loop, another one is for writing serial communications device in dead loop. the device that was created with the FILE_FLAG_OVERLAPPED flag, and i create the OVERLAPPED structure with manual-reset event object. i use SetThreadPriority to do: raise the Priority of writing thread before writing serial device . raise the Priority of reading thread after writing serial device and drop writing thread to normal. keep the Priority of reading thread high after reading serial device. my p...

Hosting CSharp control in an MFC View/Dialog #2
I can host MS .NET controls in my MFC apps no bother, but If I build a CSharp control library called WidgetsLib that contains a control called UserControl1.. then use a #using directive to import the library like so: #using<C:\sw\scratch\csharp\WidgetsLib\bin\Debug\WidgetsLib.dll> using namespace WidgetsLib; and then instantiate it like: CWinFormsControl<UserControl1> m_wfUserControl; ...everything compiles fine, but at runtime I get an error like: 'An unhandled exception of type 'System.IO.FileNotFoundException' occurred in proj02.exe Additional information: Cou...

new access application
Questions about creating an .net ‘executable’ 2005 that will not remained installed once a user enters some data into the application. I also want this applcation to not require any previous software installed on a users workstation. I basically want to setup an application for new users when they are applying for insurance. This application would preferably be a run as a windows desktop application versus on the internet. Once the user enters the save or submit button, I want the application to send the data back to be processed on a Sql server 2000 or sql server 2005 database. ...

VC 7 MFC features
Can anyone give me a link to how MFC in VC 7 differs to VC 6? In particular, does VC 7 MFC support anchoring of controls (so that they automatically move/resize when the parent window moves/resizes)? http://msdn.microsoft.com/library/en-us/vccore/html/vcrefwhatsnewlibrariesvisualc70.asp http://msdn.microsoft.com/library/en-us/vcedit/html/vcoriCLibraries.asp No, but several ways to achieve that already exist. Here is one of them: http://sourceforge.net/projects/resizablelib/ --------------------------------------------------- Automate your software builds with Visual Build Pro http://ww...

An Error "Interface Not Registered" after Configuring Outlook 03
I Configured my MS office Outlook 2003 to Gmail email Client which was Partly sucessful but i am not able to send mail it gives an error message "INTERFACE NOT REGISTRED" i am not able to use Outlook please help tarun123v <tarun123v@discussions.microsoft.com> wrote: > I Configured my MS office Outlook 2003 to Gmail email Client which > was Partly sucessful but i am not able to send mail it gives an error > message "INTERFACE NOT REGISTRED" i am not able to use Outlook > please help Try this. CLick Start>Run and enter regsvr32 ole32.dll in the...

Application view does not get refreshed
Hi All, I have Intellipoint for my MS Mouse installed. I have a application with differnet dialogs views on a Frame Window. Now If I start the application the View of application does not get refresh and it flickers a lot. If I close the Intellipoint (iPoint.exe) from Task Manager, My Application works properly with out any error. Can You please tell me how to fix this issue. Do I need to take care of special Case where Intellipoint is intalled. Thanks Anup I don't have this problem, but it seems like the guys in this discussion did: http://discussion.autodesk.com/thread.jspa?thre...

STL and MFC #2
I'd like to get other's thoughts, especially the gurus like Joe and Scott. I've been trying to enhance my C++ OOP design skills and within this process, I have read several recommended books (Effective C++, Exception C++, etc). What's intriguing, is most of these authors use the STL as their framework. I know that I couldn't totally replace MFC within the Win32 context, for at the very least, the Windows controls have too much dependency on this framework. But what about the collection containers? I'd love to hear arguments for or against the usage of STL as a gener...

MFC & OpenGL & ON_WM_PAINT & no more Dialogs
Hello, I do have a question regarding the WM_PAINT callback. I subscribed my View class to WM_PAINT and implemented the OnPaint() method. This is necessary to prevent my OpenGL MFC Window from only updating once in a while. As soon as I only use the OnPaint Method I cannot see my Dialogs anymore. Whenever I open eg. the App About Dlg it does not appear until I press the ALT key. This is quite annoying, because I can't focus on my application window by clicking on it either. I would appreciate any suggestion! Cheers Gordon ...

Error opening application
We have a database that was used in Access 2003. We upgraded our computer and software and now we have Access 2007. When trying to run this database we get the error "Error in opening application: 429 Error creating CSetupInfo". Any idea what this error could mean? What other info would you need to know from me? thanks Bart Bart, is the new computer running Windows Vista? If so, see: Errors using multiple versions of Access under Vista at: http://allenbrowne.com/bug-17.html -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://...

importing VC6 dlls into VC.net (using MFC)
Hi, I'm using VS.NET 2003 on Win2000 (SP3). I am trying to import a dll developed in VC++6.0 into my VC.net project. I keep getting linker errors complaining about GetThisClass and GetThisMessageMap functions called from RUNTIME_CLASS and BEGIN_MESSAGE_MAP respectively. The problem I found was in the redefinition of these macros. The old versions, used in VC6.0 didn't have these functions. Does anybody know how can I import the dlls without re- writing them in .Net. I have too many dlls that I would like to re-use. Thanks in advance. Anna. ...

Web Based Interface for my Clients
Dear Sir: i would like to know if the MS-CRM have a web based interface for my clients, which allow him to login and create a case, also is a ticket number will be generated in orderto alllow him to track his case status through a web based interface too. thanks, The idea of CRM I believe is to use in-house and its all web based. However if you really really wanted to let your customers have access to it I don't see why you should not be able to. All you will need is to host on a public IP and get lots of licenses for your clients. Thanks and Regards Fakhruddin "wael"...