Thinking about using C++ .NET for a Project, so I do so?

This is a discussion on Thinking about using C++ .NET for a Project, so I do so? within the C# Programming forums, part of the General Programming Boards category; Edit : Moving this to the Windows board. Hi there, I'm thinking about using C++ .NET for an application which ...

  1. #1
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812

    Thinking about using C++ .NET for a Project, so I do so?

    Edit : Moving this to the Windows board.

    Hi there,

    I'm thinking about using C++ .NET for an application which must integrate closely with the Windows API. I have never used .NET before, so am wondering about the pros & cons with this app:

    Should I opt for unmanaged code, or managed?

    Will chosing managed restrict my ability to call on native win API functions in any way?

    Will chosing unmanaged restrict any ability to use any drop & drag design time features and components offered by .NET. For example, will I be back in the world of VC6 and MFC with unmanaged code?

    Will opting for managed code pose any security issues related to reverse engineering of the application?

    Thanks
    Last edited by Davros; 03-25-2004 at 10:54 AM.
    OS: Windows XP
    Compilers: MinGW (Code::Blocks), BCB 5

    BigAngryDog.com

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,138
    Seems like an easy question, but the answer, as always, is: "it depends". I'll try explain it a bit more

    I'm thinking about using C++ .NET for an application which must integrate closely with the Windows API. I have never used .NET before, so am wondering about the pros & cons with this app:
    In general, I don't think C++ is the right language to start exploring .NET. .NET is easy and flexible when used with C# ( or VB.NET ). Using it with C++ is introducing 5 more keywords to give you full control over features that were implemented so you do not have to worry about them. Basically, .NET makes C++ more complicated but is giving you the advantage of the libraries and interfaces with other .NET stuff.

    Not unlike assembly, Managed C++ is a wise choice for the 5% of tasks where you need it, and a major holdup for the other 95%.

    Don't get me wrong, I like it and I'm the only one writing Managed C++ in our company, but it's only useful if you apply it to a job that needs it.

    Should I opt for unmanaged code, or managed?
    Depends on what you want to do. C++ is the right choice for WinAPI anyway. If you need to present a lot of user interfaces, or any other interface to other managed stuff, I'd go for C# and writing a Managed C++ Wrapper DLL for anything C++ you need. If you just want to explore .NET using the latest project, try to use the next one without WinAPI and use C#.

    Depending on how much WinAPI you need, you can call any API function from C#. But if it has a lot of pointers and handles or maybe even graphic contexts and such things, C++ is better because it has native support.

    Will chosing managed restrict my ability to call on native win API functions in any way?
    No. Obviously you can't run it on Linux with Mono anymore, but besides the obvious, you can call any function you'd call in C++ from Managed C++ ( and 99% even from C# ).

    Will chosing unmanaged restrict any ability to use any drop & drag design time features and components offered by .NET. For example, will I be back in the world of VC6 and MFC with unmanaged code?
    Yes and no. You can combine managed and unmanaged code in one assembly. For example, we have a lot of legacy C++ code. We have many dlls that use this code and a wrapper functionallity to expose it to .NET. Bottom line: You can use "normal" C++ and C++.NET in the same assembly (.exe/.dll). Now it depends on what you want your GUI to be. If you want .NET ( having built GUIs with both, I highly recommend that ) you can have your complete GUI in Managed C++ using the .NET library and your backend in pure C++ calling WinAPI. All in one Visual Studio Project and compiling to a single .exe ( if you want that. Obviously you can split it into as many .dlls as you see fit, but you don't need to, unlike the earlier VB/C++ combinations )

    Will opting for managed code pose any security issues related to reverse engineering of the application?
    Indeed. If you leave it as it is, at least the Managed C++ part can be reverse engineered back into sourcecode with tools that are part of the free downloadable SDK. There are obfuscators for this purpose, I think one comes with Visual Studio 2003.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User
    Join Date
    Apr 2004
    Posts
    21
    good thought but ,
    be aware you gonna stuck yourself in managed unmanaged layers. so u should be very careful and patient.

    u can call native api from the heart of managed codes by using IT JUST WORK weid and wonderfull technology .simply it just works !

    u've seen sample codes ...
    but if u encountered any name clashes between managed and unmanaged u may act as follow:


    #include <windows.h>
    #pragma push_macro("MessageBox")
    #undef MessageBox
    public __gc class foo
    {
    public:
    void func();
    }
    void foo::func()
    {
    createprocess(blahblah);//unmanaged
    MessageBox::Show("blahbla");//managed
    }


    look at this snapcode ,emm
    vc .net is in infancy ,it is growing .
    hold up until whisbey ,guys in Microsoft have changed lots of features.

    but if u want to keep u'rself far from danger ,simply use C# and
    attributes to call unmanaged ; simple and pretty !

    if i were u i simply used unmanaged c/c++ and it all works!

  4. #4
    Registered User
    Join Date
    Apr 2004
    Posts
    26
    What Kind of project are you planning on writing? because if it requires speed in development then you might want to opt dor learning C#. It's not a hard language at all and makes windows GUI programming about 10 times faster. Coming from a C++ background i learned the language in about 3 days so that i know it pretty well.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. multiple errors generated by socket headers
    By nocturna_gr in forum Windows Programming
    Replies: 5
    Last Post: 12-16-2007, 05:33 PM
  2. Dynamic Binding
    By gpr1me in forum C++ Programming
    Replies: 1
    Last Post: 03-24-2006, 08:01 AM
  3. Resource ICONs
    By gbaker in forum Windows Programming
    Replies: 4
    Last Post: 12-15-2003, 06:18 AM
  4. .NET; What is your opinion?
    By CompiledMonkey in forum A Brief History of Cprogramming.com
    Replies: 33
    Last Post: 05-07-2002, 12:49 AM
  5. .net
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 02-15-2002, 12:15 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21