Jump to content
  • Advertisement
Sign in to follow this  
bug_aonz

[.net] How to call an win32 api with VC#.NET ???

This topic is 4825 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i need VC#.net to call an .dll to use in my project.But i don't know cods that call dll and use it's function.please give me some examples,thank.

Share this post


Link to post
Share on other sites
Advertisement
I'm going to assume that you want to use an unmanaged DLL. (If you're using a managed DLL, just add it to your "References," and you're good to go!)

Otherwise, you'll need to wrap the DLL using DllImport. (This page contains a simple sample. For more samples, you might want to take a look at the Tao Framework. It is built on this concept.)

Just create a file and create the function prototypes for the stuff contained within the DLL, and apply the DllImport attribute to each prototype.

After that, you should be good to go!

HTH!

Share this post


Link to post
Share on other sites
Do u know about WRAPI.dll? it use to work with WLAN to access data (signal strength,etc.)from access point.
My problem is WRAPI.dll has its own variable type (common type such as string ,int,long but in wrapi,such as AP_DATA(i think it uses to access data from access point) ).
In wrapi source file it declares functions like this....
function name(AP_DATA *....,int ...,long ...)

Stuck! becuase c# don't know what's AP_DATA

.... Could u tell me others website which suitable for my question?.....

Share this post


Link to post
Share on other sites
bug_aonz,

You may want to check this tutorial at MSDN: Platform Invoke Tutorial. It explains how to P/Invoke, including how to use structs and pass them as pointers (thanks to the [In] and [Out] attributes).

Another useful site is pinvoke.net which is a reference containing tons of already made P/invoke definitions. Unfortunately for you, it doesn't contain WRAPI.dll yet. But it's a wiki, so please feel free to add it ;-)

Good luck,
jods

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by bug_aonz
i need VC#.net to call an .dll to use in my project.But i don't know cods that call dll and use it's function.please give me some examples,thank.


What kind of dll do you have? Is it pure c-functions? COM? C++? Interop is for c-functions. Using C++ DLLs isn't that easy, but if possible you might build it as a managed c++ project. COM is also possible.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!