The dotNet framework is pretty smart when it comes to marshalling managed to unmanaged datatypes for PInvoke calls. When you want to pass a Guid from the managed to the unmanaged world the framework knows how to transform the .Net Guid structure to a Windows GUID without you even asking for it.
Marshalling strings is usually no problem either. You can pass in a managed string and the .Net framework handles any unicode to ANSI conversions for you.
These two calls from the setupapi.dll library illustrate this. The first call takes a string describing a device-class (for example keyboard) and returns an array of Guids with usually one Guid for that device class (4D36E96B-E325-11CE-BFC1-08002BE10318 for keyboards). The classGuidListSize parameter tells the dll how big we made the guids array. If it's not big enoug we can check the requiredSize parameter after the call and call again with a bigger array.
The second call is a problem though. It's exactly the reverse of the first call. It takes a single Guid and returns a string. The problem here is that in the managed world we dont have much influence over the size of strings. That's all handled for us.
One hack could be to pass in an empty string, with zero in classNameSize, and pass in a string padded with the appropriate amount of spaces the second time around to make it big enoug to hold the amount of characters in requiredSize but that would be a bit messy.
The preferred way is to pass in a StringBuilder class instead of a string. We can use the Capacity property of the StringBuilder to make it any size we want.