[.net] How to call an win32 api with VC#.NET ???
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.
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!
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!
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?.....
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?.....
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
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
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement