Strings

The string attribute indicates the parameter is a pointer to an array of type char, byte, or w_char. As with a conformant array, the size of a string parameter is determined at run time. Unlike a conformant array, the developer does not have to provide the length associated with the array — the string attribute tells the stub to determine the array size by calling strlen. A string attribute cannot be used at the same time as the length_is or last_is attributes.

The in, string attribute combination directs the stub to pass the string from client to server only. The amount of memory allocated on the server is the same as the transmitted string size plus one.

The out, string attributes direct the stub to pass the string from server to client only. The call-by-value design of the C language insists that all out parameters must be pointers. (The key idea is that by passing the value of the address, the function can indirectly change the value stored at that address. If the value itself were passed, the function would only be able to modify its local copy of the value. For a more extensive explanation of the difference between call by value and call by reference, see any C language programming book published by Microsoft Press.)

The out parameter must be a pointer and, by default, all pointer parameters are reference pointers. The reference pointer does not change during the call — it points to the same memory as before the call. For string pointers, the additional constraint of the reference pointer means the client must allocate sufficient valid memory before making the remote procedure call. The stubs transmit the string indicated by the out, string attributes into the memory already allocated on the client side.