There is some code in the Lazarus sources at$LazarusDir/components/codetools/tests/testcompreaderwriterpas.pas