We present high-resolution (R similar to 50,000) observations of near-IR transitions of CO and CN of the five known hydrogen-deficient carbon (HdC) stars and four R Coronae Borealis (RCB) stars. We perform an abundance analysis of these stars by using spectrum synthesis and state-of-the-art MARCS model atmospheres for cool hydrogen-deficient stars. Our analysis confirms reports by Clayton and colleagues that those HdC stars exhibiting CO lines in their spectrum and the cool RCB star SAps are strongly enriched in O-18(with O-16/(18)Oratios ranging from 0.3 to 16). Nitrogen and carbon are in the form of N-14 and C-12, respectively. Elemental abundances for CNO are obtained from C I, Ci2, CN, and CO lines. Difficulties in deriving the carbon abundance are discussed. Abundances of Na from Na I lines and S from S I lines are obtained. Elemental and isotopic CNO abundances suggest that HdC and RCB stars may be related objects, and that they probably formed from a merger of an He white dwarf with a C-O white dwarf.