Take a look at WNetAddConnection2 and WNetAddConnection3 APIs and see if this is what you are looking for.