There is no software solution for this. If there is, then it relies on some hardware. The answer is an ammeter. Just place the ammeter between the power source and the device. The ammeter will measure the current flow. Then you can do some calculations to figure the power usage. This should be quite trivial for devices like hard drives and even the whole computer, but it would be somewhat more involved for something like a cpu or a pci card.