Effect is a valid pointer to ID3DXEffect...
[pascal]
if HasShader then
begin // Render with shaders
Effect.SetTechnique;
Effect.Shader._Begin(@Passes, 0); // begin shader

for i := 0 to Passes-1 do
begin
Effect.Shader.BeginPass(i); // Render passes
FScreen.Device.DrawPrimitive(PrimitiveType, StartVertex, PrimitiveCount);
Effect.Shader.EndPass; // End render pass
end;

Effect.Shader._End; // end shader[/pascal]

Is it possible to set textures outside the BeginPass?

On the lights, some shaders are using a light. do I need to pass a light to the shader or can I just enable the lights trough DirectX?
for example: I have a shader that uses bumpmapping from 1 light. The light is decleard as "float4 lightPos;". So it means I need to pass the light information to the shader? How do I do that is my object is lighten from 4 lights? Do I need to declear 4 light points in my shader? What if I have 2 object, 1 has 2 light, the other has 5 ?