We had this explained to us in December 2006; of course, it may have changed since then, but it's more recent than the 1998 info posted earlier (thanks for that tip, regardless!).
From what we understand, lanyards are pre-filled and given out prior to each shift (though it seems that cast members may have some say as to whether or not they wish to participate, the vast majority do). They may swap out a few before they start work, but by and large, they just pick up their lanyard and go.
If you didn't already know this, cast members have pins that can only be obtained by trading with them - pins in the "cast lanyard" series. You can spot these by seeing a tiny Mickey head on the front of the pin, and on the back, it will have "cast lanyard" or "CL" stamped on it. Note that the "hidden Mickey" series of trading pins (which are limited editions) also have a Mickey head on the front, and while these are less common than regular pins (sometimes far less common), these are available for purchase to the general public.
I have read that Disney will be merging cast lanyard and hidden Mickey pin lines in the future. (why?)
Finally, cast members can purchase cast exclusive pins. While these are frequently inexpensive, they are almost always very limited in edition, and are not available to the public. Odds of finding one of these in the parks are pretty much nil, since these must be purchased. I can't imagine a cast member trading one of these away unless they were specifically trying to make someone's day.