Results 1 to 4 of 4

Thread: [2005] Interact with C++ Project

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2005
    Posts
    48

    [2005] Interact with C++ Project

    Hey,

    I was wondering how do you interact with a C++ project in VB that are both in the same solution. I tried to Add Reference - Projects but I got an error message.

    Actually the file in the C++ project is actually a C file so I don't know if that complicates things anymore. In the Debug folder I see the project is outputted as a .obj file if that helps.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Interact with C++ Project

    There are really only three ways that a .NET app can interact with external libraries. If the library is a .NET assembly then it can be referenced directly. if the library isa COM component then it can be referenced indirectly via COM interop. Otherwise the library would have to export functions which can then be declared as external functions using either the 'Declare' statement or the 'DllImport' attribute. If your C++ project is not managed then the first option is not open to you. If you have not compiled the C++ project as a COM component then the second option is not open to you either. If you're using C code files then the third option is likely to be the only one available to you.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2005
    Posts
    48

    Re: [2005] Interact with C++ Project

    Hmm, looks like I have another problem that may not be fixable. Right now the C++ Project outputs values to the console using printf().

    Is there a way to call the main executable and then store whatever values are outputting into a string using C#? This is pretty far fetched and I wouldn't be surprised if this isn't possible...

  4. #4
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [2005] Interact with C++ Project

    Quote Originally Posted by r_barlow
    Hmm, looks like I have another problem that may not be fixable. Right now the C++ Project outputs values to the console using printf().

    Is there a way to call the main executable and then store whatever values are outputting into a string using C#? This is pretty far fetched and I wouldn't be surprised if this isn't possible...
    Checkout the CodeBanks... Gigemboy has an example on how to redirect command window's output into your app.
    http://www.vbforums.com/showthread.p...utput+redirect

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