Help! Calling mmsystem.api to record .wav files.

I am trying to record sound directly into memory using a soundblaster pro
card.  I am trying to call the mmsystem.api to record.  The first two calls
work, but the waveinopnen does not.  This is the error message it returns:
"The specified format is not supported or cannot be translated...."

If I use lpformat as Ppcmwaveformat and call it as
  wave := waveinopen(lphwavein, 0, @lpformat, handl, 0,
    callback_window);
I get the same error message.

What am I doing wrong?  Please post to this group because my mailer is not
working.

unit Snd1u1;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, mmsystem, StdCtrls, Buttons;

type
  TForm1 = class(TForm)
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.BitBtn1Click(Sender: TObject);
var
  wave, result, wavcapsize : word;
  capab : pwaveincaps;
  lpformat : pwaveformat;
  lphwavein : phwavein;
  lptext : pchar;
  handl : hwnd;

begin
  new(capab);
  new(lphwavein);
  new(lpformat);
  getmem(lptext, 256);
  wavcapsize := sizeof(capab^);

{These two calls work}
  result := waveingetnumdevs-1;
  result := waveingetdevcaps(result, capab, wavcapsize);
{At this point I know I have a card present and the type. etc.}

  with lpformat^ do
  begin
    wformattag := wave_format_pcm;
    nchannels := 1;
    nsamplespersec := 11025;
    navgbytespersec := 11025;
    nblockalign := 1;
  end;
  handl := handle;

{This line dosen't work, it returns error number 32.}
  wave := waveinopen(lphwavein, 0, lpformat, handl, 0,
    callback_window);

  result := waveingeterrortext(wave, lptext, 256);
  messagedlg(strpas(lptext), mtinformation, [mbok],0);
  application.processmessages;
  result := waveinclose(lphwavein);
  dispose(capab);
  dispose(lphwavein);
  dispose(lpformat);
  freemem(lptext, 256);
end;

procedure TForm1.BitBtn2Click(Sender: TObject);
begin
  close;
end;

end.

d...@paschools.pa.sk.ca
http://pasd2.paschools.pa.sk.ca