[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

How to include header file used by DLL

Dv

3/16/2007 2:10:00 PM

I have a API lib (written in C/C++) that can be used by C/C++ project.
Now, I'm adding support to C# project.

I changed the Lib to DLL. This is easy. However, I have no idea how to
deal with the structures and constants that used to be defined in the
header file of the lib.

Where should I define them that they can be commonly used by the DLL, C
++ and C#, and also is readable to their developers from their IDEs?

Thanks!
-Dev

3 Answers

SimeonArgus

3/16/2007 2:32:00 PM

0

On Mar 16, 9:09 am, "Dv" <dev...@gmail.com> wrote:
> I have a API lib (written in C/C++) that can be used by C/C++ project.
> Now, I'm adding support to C# project.
>
> I changed the Lib to DLL. This is easy. However, I have no idea how to
> deal with the structures and constants that used to be defined in the
> header file of the lib.
>
> Where should I define them that they can be commonly used by the DLL, C
> ++ and C#, and also is readable to their developers from their IDEs?
>
> Thanks!
> -Dev


I think I understand the question. By default, the C# engine will know
how to comile your existing function calls, constants, etc based on
the DLL.

However, if you want those constants to pop up in the intellisense
menus, then you may be pushing your luck. It won't auto-load them into
Intellisense for you.

Instead, you may want to create new declarations in C# as constants
that mimic your C++ constants. The problem is that now you have two
sets of "constants" to maintain.

Hope that helps.

--Sim

Dv

3/16/2007 4:01:00 PM

0

On Mar 16, 10:32 am, "SimeonArgus" <simeontr...@gmail.com> wrote:
> On Mar 16, 9:09 am, "Dv" <dev...@gmail.com> wrote:
>
> > I have a API lib (written in C/C++) that can be used by C/C++ project.
> > Now, I'm adding support to C# project.
>
> > I changed the Lib to DLL. This is easy. However, I have no idea how to
> > deal with the structures and constants that used to be defined in the
> > header file of the lib.
>
> > Where should I define them that they can be commonly used by the DLL, C
> > ++ and C#, and also is readable to their developers from their IDEs?
>
> > Thanks!
> > -Dev
>
> I think I understand the question. By default, the C# engine will know
> how to comile your existing function calls, constants, etc based on
> the DLL.
>
> However, if you want those constants to pop up in the intellisense
> menus, then you may be pushing your luck. It won't auto-load them into
> Intellisense for you.
>
> Instead, you may want to create new declarations in C# as constants
> that mimic your C++ constants. The problem is that now you have two
> sets of "constants" to maintain.
>
> Hope that helps.
>
> --Sim

Sim, thanks for your reply! No, I didn't mean the Intellisense. I
meant a text file (instead of a binary file, such as DLL) that is
displayable in IDE with all the structures and constants defined in
there.

I expect that users of my DLL could reuse the declarations coming with
the DLL either in the form of header file or some other way that's
acceptable by both C++ and C#.


Nicholas Paldino [.NET/C# MVP]

3/18/2007 1:13:00 AM

0

Dv,

You can't. You have to declare the structures that the functions use in
C#. Your best bet would be to declare them in the assembly that utilizes
the DLL functions in C#.

You can not use the same header file in C++ as you do in C#, and
vice-versa.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com

"Dv" <dev618@gmail.com> wrote in message
news:1174054189.550331.293470@d57g2000hsg.googlegroups.com...
>I have a API lib (written in C/C++) that can be used by C/C++ project.
> Now, I'm adding support to C# project.
>
> I changed the Lib to DLL. This is easy. However, I have no idea how to
> deal with the structures and constants that used to be defined in the
> header file of the lib.
>
> Where should I define them that they can be commonly used by the DLL, C
> ++ and C#, and also is readable to their developers from their IDEs?
>
> Thanks!
> -Dev
>