Results 1 to 8 of 8

Thread: Visual C++ Question...

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2002
    Posts
    382

    Visual C++ Question...

    I have a few questions concerning Visual C++ Managed code. I am reading the C++ Express page at microsoft and I'm confused, Does Visual C++ use the .Net framework like VB does? Also does Visual C++ code produce a assembly like VB does that can be decompiled with Reflector or one of many other free tools available?

    Last question, Microsofts site says this:
    Build Windows native and .NET Framework applications

    I'm assuming that if you create Native code, that means you don't need the framework right?

    I'm confused

    Hinder

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,430

    Re: Visual C++ Question...

    Anything that is "managed" is using the Framework and anything that is "unmanaged" or "native" is not. "Managed" means that the executable is a .NET assembly containing MSIL and execution is managed by the Framework. "Native" means the executable is in machine code native to the platform on which it is being executed. If you write a managed application in C++.NET and compile it it will produce a .NET assembly that is basically indistinguishable from one that was compiled from a project written in VB.NET, C# or any other .NET language. Unlike VB.NET and C#, the Microsoft C++ IDE allows you to create native executables as well as .NET assemblies. Native code neither knows nor cares about the .NET Framework.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2002
    Posts
    382

    Re: Visual C++ Question...

    Quote Originally Posted by jmcilhinney
    Anything that is "managed" is using the Framework and anything that is "unmanaged" or "native" is not. "Managed" means that the executable is a .NET assembly containing MSIL and execution is managed by the Framework. "Native" means the executable is in machine code native to the platform on which it is being executed. If you write a managed application in C++.NET and compile it it will produce a .NET assembly that is basically indistinguishable from one that was compiled from a project written in VB.NET, C# or any other .NET language. Unlike VB.NET and C#, the Microsoft C++ IDE allows you to create native executables as well as .NET assemblies. Native code neither knows nor cares about the .NET Framework.

    Ok thanks, So I guess my question would be, can you code in Managed code and then compile the mananged code to Native code to keep people from decompiling your code?

    Hinder

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,430

    Re: Visual C++ Question...

    Generally no. If you want to use the Framework class library then you have to compile to a managed assembly. There are tools around that will convert a managed assembly into a native executable (I'm not sure if that description is technically accurate) by compiling all the required parts of the Framework into it. Salamander is such a tool but I believe that it is quite expensive. You also lose many of the advantages that managed code provides, such as bug fixes in the Framework propagating to your app, etc.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2002
    Posts
    382

    Re: Visual C++ Question...

    Quote Originally Posted by jmcilhinney
    Generally no. If you want to use the Framework class library then you have to compile to a managed assembly. There are tools around that will convert a managed assembly into a native executable (I'm not sure if that description is technically accurate) by compiling all the required parts of the Framework into it. Salamander is such a tool but I believe that it is quite expensive. You also lose many of the advantages that managed code provides, such as bug fixes in the Framework propagating to your app, etc.
    Alright so here's my delema then, I have a server I have coded that has a Serial Key checking function. There's nothing inovative in my server code so if it's decompiled, no big deal. But I have to figure out how to hide my Serial Key checking function, it's 30 lines of code. I was thinking, how hard would it be to just create my function in a Native C++ DLL then call the DLL from my VB server? I don't code in C++ but I think I could translate my serial key code to C++ with a little time. I just have never called an external DLL written in anything but VB so I'm not sure how to go about it...

    Hinder

  6. #6
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,430

    Re: Visual C++ Question...

    Quote Originally Posted by Hinder
    Alright so here's my delema then, I have a server I have coded that has a Serial Key checking function. There's nothing inovative in my server code so if it's decompiled, no big deal. But I have to figure out how to hide my Serial Key checking function, it's 30 lines of code. I was thinking, how hard would it be to just create my function in a Native C++ DLL then call the DLL from my VB server? I don't code in C++ but I think I could translate my serial key code to C++ with a little time. I just have never called an external DLL written in anything but VB so I'm not sure how to go about it...

    Hinder
    If you can make your unmanaged C++ library a COM component then you can reference it just like any other COM library, which is essentially the same as a .NET assembly. The other option is to export your methods from the native library and then call them like (or in fact as) API functions. I don't think exporting methods from C++ is difficult, although I couldn't tell you for sure. I think that it's just a matter of a keyword or two in the declaration.

  7. #7
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Visual C++ Question...

    There are several examples of how to make a win32 dll which is callable from VB in the VB6 and API forums and probably the C++ forum also. It's pretty simple.

  8. #8
    Junior Member
    Join Date
    Mar 2006
    Posts
    27

    Re: Visual C++ Question...

    Post deleted
    Last edited by stijn.adriaensens; Jun 8th, 2008 at 09:29 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width