Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. use C header file in a VB project

use C header file in a VB project

Scheduled Pinned Locked Moved Visual Basic
csharpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Marc Soleda
    wrote on last edited by
    #1

    Hi all, I'm developing an application in VB2005.Net 2.0 and I would like to use a C header file that contains many structs that I need in the project. This structs are going to change quite often so I wouldn't like to migrate the structs from the C file to VB code each time that the header file changes. The best thing for me would be to include the '.h' file directly into my project so I could access it directly. Is it possible to do it in any way? Could it be possible to do it encapsulating the '.h' file into a library and then reference it from the VB project? Thanks in advance for any idea you have, Marc Soleda

    ... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits

    C 1 Reply Last reply
    0
    • M Marc Soleda

      Hi all, I'm developing an application in VB2005.Net 2.0 and I would like to use a C header file that contains many structs that I need in the project. This structs are going to change quite often so I wouldn't like to migrate the structs from the C file to VB code each time that the header file changes. The best thing for me would be to include the '.h' file directly into my project so I could access it directly. Is it possible to do it in any way? Could it be possible to do it encapsulating the '.h' file into a library and then reference it from the VB project? Thanks in advance for any idea you have, Marc Soleda

      ... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Perhaps if you make a C++/CLI dll, you could do it.

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      M 1 Reply Last reply
      0
      • C Christian Graus

        Perhaps if you make a C++/CLI dll, you could do it.

        Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        M Offline
        M Offline
        Marc Soleda
        wrote on last edited by
        #3

        I've done it but I just have access to the struct name and not to its subelements. I mean: In the .h header file: .... public struct S_ERRORS{ unsigned char uHall2; unsigned char uHall1; } ... Inside the VB project, I can declare a S_ERRORS variable but I cannot access to its element: uHall1, uHall2 Is there any way to access to this elements? Thanks in advance, Marc Soleda

        ... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits

        D 1 Reply Last reply
        0
        • M Marc Soleda

          I've done it but I just have access to the struct name and not to its subelements. I mean: In the .h header file: .... public struct S_ERRORS{ unsigned char uHall2; unsigned char uHall1; } ... Inside the VB project, I can declare a S_ERRORS variable but I cannot access to its element: uHall1, uHall2 Is there any way to access to this elements? Thanks in advance, Marc Soleda

          ... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Marc Soleda wrote:

          I've done it

          Done what?? Did you compile this into a MANAGED (C++ CLI) .DLL or into a normal Windows library .DLL (unmanaged code). If unmanaged, you won't be able to use the structures defined in the .DLL.

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007, 2008

          M 1 Reply Last reply
          0
          • D Dave Kreskowiak

            Marc Soleda wrote:

            I've done it

            Done what?? Did you compile this into a MANAGED (C++ CLI) .DLL or into a normal Windows library .DLL (unmanaged code). If unmanaged, you won't be able to use the structures defined in the .DLL.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007, 2008

            M Offline
            M Offline
            Marc Soleda
            wrote on last edited by
            #5

            Into a C++/CLI dll: I can declare a structure variable defined in the library but no access to its elements

            ... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups