I tried pointerToCString for the TekVisa DLL (DLL to control measurement instruments from Tektronix) which did not work for opening an instrument session. The second answer in this thread is better but misses a detail: The byte array has to be terminated with a 0. My code below works. (The instrument variable is of type String and contains the instrument string, for instance "TCPIP::::INSTR".)
Interestingly, pointerToCString works when sending a command to the instrument, for instance viWrite("*IDN?").
Pointer<Byte> pViString = Pointer.allocateBytes(instrument.length() + 1);
byte[] instrumentBytes = instrument.getBytes();
pViString.setBytes(instrumentBytes);
pViString.setByteAtIndex(instrument.length(), (byte) 0);