The tricky thing about creating an execute buffer is figuring out how much memory to allocate for it. There are two basic strategies for determining the correct size:
The hardware determines the size of the execute buffer. You can retrieve this size by calling the IDirect3DDevice2::GetCaps method and examining the dwMaxBufferSize member of the D3DDEVICEDESC structure. Typically, 64 KB is a good size for execute buffers when you are using a software driver, because this size makes the best use of the secondary cache. When your application can take advantage of hardware acceleration, however, it should use smaller execute buffers to take advantage of the primary cache.
After filling in D3DEXECUTEBUFFERDESC structure describing your execute buffer, you can call the IDirect3DDevice::CreateExecuteBuffer to create it.
For an example of calculating the size of the execute buffer and creating it, see Creating the Scene, in the Direct3D Execute-Buffer Tutorial.