Interpreting Binding Information

Microsoft RPC enables your client and server programs access to and interpret the information in a binding handle. This does not mean that you can or should try to access the contents of a binding handle directly. Microsoft RPC provides functions that set and retrieve the information in binding handles.

To get the information in a binding handle, pass the handle to RpcBindingToStringBinding. It returns the binding information as a string. For every call to RpcBindingToStringBinding, you must have a corresponding call to the function RpcStringFree.

You can call the function RpcStringBindingParse to parse the string you obtain from RpcBindingToStringBinding. This function allocates strings to contain the information it parses. If you do not want it to parse a particular piece of binding information, pass a NULL as the value of that parameter. Be sure to call RpcStringFree for each of the strings it allocates.

The following code fragment illustrates how an application might call these functions.

RPC_STATUS status;
UCHAR *lpzStringBinding;
UCHAR *lpzProtocolSequence;
UCHAR *lpzNetworkAddress;
UCHAR *lpzEndpoint;
UCHAR *NetworkOptions;
 
// The variable hBindingHandle is a valid binding handle.
 
status = RpcBindingToStringBinding(hBindingHandle,&lpzStringBinding);
// Code to check the status goes here.
 
status = RpcStringBindingParse(
    lpzStringBinding,
    NULL,
    &lpzProtocolSequence;
    &lpzNetworkAddress;
    &lpzEndpoint;
    &NetworkOptions);
// Code to check the status goes here.
 
// Code to analyze and alter the binding information in the strings
// goes here.
 
status = RpcStringFree(&lpzStringBinding);
// Code to check the status goes here.
 
status = RpcStringFree(&lpzProtocolSequence);
// Code to check the status goes here.
 
status = RpcStringFree(&lpzNetworkAddress);
// Code to check the status goes here.
 
status = RpcStringFree(&NetworkOptions);
// Code to check the status goes here.

The preceding sample code calls the functions RpcBindingToStringBinding and RpcStringBindingParse to get and parse the information in a valid binding handle. Note that the value NULL was passed as the second parameter to RpcStringBindingParse. This causes that function to skip parsing the object UUID. Since it does not parse the UUID, RpcStringBindingParse will not allocate a string for it. This technique enables your application to only allocate memory for the information you are interested in parsing and analyzing.