<p>How would it be possible to capture the audio programmatically? I am implementing an application that streams in real time the desktop on the network. The video part is finished. I need to implement the audio part. I need a way to get PCM data from the sound card to feed to my encoder (implemented using Windows Media Format). </p>

<p>I think the answer is related to the openMixer(), waveInOpen() functions in Win32 API, but I am not sure exactly what should I do.</p>

<p>How to open the necessary channel and how to read PCM data from it?</p>

<p>Thanks in advance.</p>

I don't think there is a direct way to do this using the OS - it's a feature that may (or may not) be present on the sound card.  Some sound cards have a loopback interface - Creative calls it "What U Hear".  You simply select this as the input rather than the microphone, and record from it using the normal waveInOpen() that you already know about.
If the sound card doesn't have this feature then I think you're out of luck other than by doing something crazy like making your own driver.  Or you could convince your users to run a cable from the speaker output to the line input :)