In addition to the Dupont Tyvek membrane product I have use the their FlexWrap product around window and door framing. See:http://www2.dupont.com/Tyvek_Weatheriza ... rapnf.html
Several years ago I replace all the windows in my home with new construction (not replacement) Anderson windows. Before each window was install I used the FlexWrap product around the perimeter of the window opening. It's a very sticky rubbery product. You get one chance to get it stuck to the right spot. There are two products, one for straight runs and one for curves or overlaps. Properly applied there is no way water will get in. I'm very pleased with the product. Like all things, it needs to be applied carefully and properly. Be sure to study the application guides on the link "gaw" referenced. You need to use the product and procedure that applies to your wall/siding/brick/etc. Caulking is never a proper fix. You need a system the diverts water even if the caulking fails.