Connecting to a remote machine using Win32API and Ruby

I haven't used the Win32 API in a while as most of my time is spent in *nix as of late, but when I saw this post on the Ruby mailing list, I thought it'd be a good topic to address.  The Win32 API provides a number of different ways of connecting to machines or other network resources WNetAddConnection, WNetAddConnection2, and WNetAddConnection3.  We'll be using WNetAddConnection2, which supersedes WNetAddConnection, and we won't be using a dialog box which is what WNetAddConnect3 is for.  If you want to read about the details check out the MSDN Documentation (Namely, the dwFlags section).  The issue Jon was running in to comes from the NETRESOURCE structure that must be passed that gives info about the resource being connected to, again you can find the full API doc at MSDN, but all sections must be specified.  Here is my quick example, keeping the same output as Jon had requested, as usual, if all goes well with your remote machine you should get a return value of 0. Feel free to clone and adjust as needed. Any suggestions? Feel free to leave them in the comments!
## Complementary Process Diagnostic With 30 minutes spent looking over your existing pipeline or process, we can diagnose the root cause(s) of slow releases or bugs. After 30 minutes on the phone or Skype with me, you will: 1. Understand why your existing process may be allowing bugs to reach production and slow you down 1. Learn ways you can increase the speed that features reach customers 1. Have a list of ideas for improving your release process We’ll have to move fast, of course, to get through all this in 30 minutes but don’t worry, I’ll keep us on track. To receive your meeting agenda and scheduling instructions, enter your email address below and click the button.