It is well known that the existence of more than two ends in the sense of J.R. Stallings for a finitely generated discrete group G can be detected on the cohomology group H1(G,R[G]), where R is either a finite field, the ring of integers or the field of rational numbers. It will be shown (cf. Theorem A*) that for a compactly generated totally disconnected locally compact group G the same information about the number of ends of G in the sense of H. Abels can be provided by dH1(G, Bi(G)), where Bi(G) is the rational discrete standard bimodule of G, and dH1(G,-) denotes rational discrete cohomology as introduced in [6]. As a consequence one has that the class of fundamental groups of a finite graph of profinite groups coincides with the class ...