After setting a material object's properties, you can retrieve its material handle by calling the IDirect3DMaterial3::GetHandle method. Direct3D Immediate Mode uses the D3DMATERIALHANDLE data type to declare material handle variables.
By retrieving the material handle, you are effectively creating an association between the material and a particular Direct3D device. The material handle represents that association — the handle you retrieve can only be used with that device. To use the material with another device, you must retrieve another handle specific to that device.
The GetHandle method accepts two parameters: the address of an IDirect3DDevice3 interface, and the address of a variable that will contain the resulting material handle after the call returns. Upon retrieving the material's handle, you can use it during rendering as often as you need. For more information, see Selecting a Material for Rendering.