You can create a Direct3D interface object by calling the IDirectDraw::QueryInterface method, as follows:
lpDirectDraw->QueryInterface(
IID_IDirect3D, // IDirect3D interface ID
lpD3D); // Address of a Direct3D object
The object referred to by an IDirect3D interface contains a list of viewports, lights, materials, and devices. You can use the methods of the IDirect3D interface to create other objects or to find Direct3D devices.