Is it possible to put a hard drive from one computer into another? If so, how?

I'm asking if I can put the same type of hard drive into another computer and use it. The computers they came from are not alike. The old one came from a Dell Optiplex (of which model I can't remember) with a Pentium 4 and 2gb of ram, and the computer I'm putting it in is a Lenovo ThinkCentre m58p with a Core 2 Duo at 3.0 ghz and 4gb of ram. I already know how to take out the hard drive from the Lenovo Thinkcentre. I'm simply asking if I can replace the hard drive in there with one from another computer, and if so, how.

The path of least resistance would be to put the other drive into the Lenovo but then you'd do a Fresh install of Windows or the operating system of your choice.

It seems to me that you're trying to put the C: drive from one PC into another while using the same software. This can work but often times there will be issues.

if it does work then you will face driver issues that you'll have to deal with by reinstalling drivers. Sometimes the driver issues will cause an instant BSOD which can only be dealt with in Safe Mode.

You could potentially have problems with the Windows Product key if you're using Windows 7 but all you have to do here is enter the product key that's tied to the Lenovo. Even if you reinstall the OS, you will have to enter the product key with Windows 7. Windows 10 stores the product key for your PC in it's database, so if you swap drives or reinstall then you will have no issues.

I've placed a drive from one custom build into another and I've had almost no issues, but branded PC's can be a lot harder to work with because the manufacturer takes care of the drivers. In fact, if you need drivers then you will have to download them from the manufacturer's website.

This works so much better when you tell us the makes & models of the parts involved, especially the part you're trying to switch.