Here's a slightly modified version of a function I started writing for my engine, but gave up on after I decided that D3DX did a much better job.
You will need to have created the texture with the correct size etc., and I think it has to be in D3DPOOL_MANAGED.
It only handles A8R8G8B8 textures at the moment.
[pascal]procedure LoadTextureFromBitmap(Bitmap: TBitmap; Texture: IDirect3DTexture8; ColorKey: TD3DColor);
var
hr: HResult;

surf: IDirect3DSurface9;
lrect: TD3DLocked_Rect;
i, j: Integer;
sbits, dbits: Pointer;
begin
// Get surface of texture
hr := Texture.GetSurfaceLevel(0, surf);
if (hr <> D3D_OK) then begin
raise Exception.Create('Get Surface Level '
+ '''' + DXGetErrorString9(hr) + '''');
end;
// Lock surface
hr := surf.LockRect(lrect, nil, 0);
if (hr <> D3D_OK) then begin
raise Exception.Create('LockRect '
+ '''' + DXGetErrorString9(hr) + '''');
end;
// Convert to 32bit pixel format
Bitmap.PixelFormat := pf32bit;
// Copy Pixel Data with colour keying
for i := 0 to (Bitmap.Height - 1) do begin
dbits := lrect.pBits;
sbits := Bitmap.ScanLine[i];
for j := 0 to (Bitmap.Width - 1) do begin
if ((PCardinal(sbits)^) and $00FFFFFF) = (ColorKey and $00FFFFFF) then
PCardinal(dbits)^ := $00000000
else
PCardinal(dbits)^ := PCardinal(sbits)^ or $FF000000;

sbits := Pointer(Integer(sbits) + 4);
dbits := Pointer(Integer(dbits) + 4);
end;

lrect.pBits := Pointer(Integer(lrect.pBits) + lrect.Pitch);
end;
// Unlock surface
hr := surf.UnlockRect;
if (hr <> D3D_OK) then begin
raise Exception.Create('UnlockRect '
+ '''' + DXGetErrorString9(hr) + '''');
end;
// Release the surface interface
surf := nil;
end;[/pascal]

Hope this helps.

BTW: I notice there are still some problems with the forum's syntax highlighting!