Using a win32 application in c#

  • Thread starter vivekanandaprasanth
  • Start date
V

vivekanandaprasanth

hi,

I am entirely new to the C#. Now I have a win32 application (this is a
win32 library not a DLL) which I want to use in a C# application.
Can any one please let me know how I can use this win32 library in my
C# application. May be in a step by step
procedure...........................:)

Actually can any one explain in words but in a step by step how I can
achieve that
 
P

Pavel Minaev

hi,

I am entirely new to the C#. Now I have a win32 application (this is a
win32 library not a DLL) which I want to use in a C# application.
Can any one please let me know how I can use this win32 library in my
C# application. May be in a step by step
procedure...........................:)

Actually can any one explain in words but in a step by step how I can
achieve that

You cannot use a static C++ library in a C# application directly. But
you have two workarounds:

1) Link that static library into an unmanaged DLL, and use that via P/
Invoke
2) Use C++/CLI to wrap all functions in the static library into
managed class methods, and use that normally via C#
 
V

vivekanandaprasanth

Thanks for the help.........

But if you dont mind can u just please let me know how to link my
static library to an unmanaged DLL. I know how to invoke that using
the P/Inoke. The entire problem is how to link my static library to an
unmanaged DLL
 
P

Pavel Minaev

But if you dont mind can u just please let me know how to link my
static library to an unmanaged DLL. I know how to invoke that using
the P/Inoke. The entire problem is how to link my static library to an
unmanaged DLL

Let's say you have a library, foo.lib, which contains a global
function called Foo. You can build a DLL out of it like this:

link foo.lib /out:foo_dll.dll /dll /export:Foo

If you have many functions that you want to export, you might want to
write a .def file instead of using /export. Read here for more details
on this:

http://msdn.microsoft.com/en-us/library/28d6s79h.aspx
 
V

vivekanandaprasanth

Let's say you have a library, foo.lib, which contains a global
function called Foo. You can build a DLL out of it like this:

  link  foo.lib  /out:foo_dll.dll  /dll  /export:Foo

If you have many functions that you want to export, you might want to
write a .def file instead of using /export. Read here for more details
on this:

http://msdn.microsoft.com/en-us/library/28d6s79h.aspx

thanks for the reply
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top