The most popular varieties of the P7 were the P7M8 and the P7M13, which Hans carried.
The P7's odd, slanted appearance of the handle is because there is an extention underneath the trigger. This extention is an experimental technology called a "handle cocker", which allows you to cock the gun without having to pull the slide or hammer back.
The P7 has been dubbed the "self-loading pistol" because of the handle mounted safety and usually costs around $1,000. So the exotic gun is appropriate for an upper class terrorist like Gruber because of its expensive price.
There are numerous variants of the HK P7. These include the PSP (Police Selfloading Pistol), P7, P7PT8, P7M13, P7M8, P7K3, P7M10 and the P7M7. The P7M7 was an extremely rare .45 ACP variant that was discontinued after prototype stages because it was too expensive and impractical to manufacture. It had a seven round magazine capacity. The P7M10 was chambered for .40 S&W, and had a ten round magazine capacity. The P7M8, P7M13, P7 and PSP pistols are all chambered in 9x19mm Parabellum. The M8 has an eight round single stack magazine and the M13 (this pistol) boasts a thirteen round double stack magazine capacity. The P7PT8 was a training firearm that was never popular, mainly because it couldn't fire live ammunition, only special training rounds. The P7K3 was a conversion pistol kit which had interchangeable barrels and slides for different calibers such as .380 ACP, .22 LR and .32 ACP.
None of these pistols remain in production; all models having been discontinued in 2008. The P7 saw widespread service around the world, in countries such as Saudi Arabia.
According to the script, Alan Rickman was supposed to carry an unspecified Walther model, likely a PP variant, but it was never explitictly identified. It can safely be assumed that the Heckler and Koch P7M13 was used in its place, as looks fancier and also bears resemblance to a Walther PP.
Hans Gruber carried a Heckler & Koch P7M13 pistol with a chrome finish during his takeover of the Nakatomi Plaza. It briefly had a supressor until Hans removed it in front of hostage Joe Takagi in an attempt to convince him to say the code to the building's vault. When Takagi refused to give him the code and stated that Hans will have to kill him, Hans fired the P7M13 at Takagi's forehead, killing him instantly.
Hans then used the pistol on Harry Ellis when his intruder John McClane refused to give the detonators to the C4 explosives and killed him with it. Hans was checking on the explosives on the roof access and placed his pistol on the roof access to look above it. After seeing McClane and successfully posed as a hostage using a fake American accent, he fiegh that we need to get out so he can get the pistol. But McClane convinces to come with him, so Hans had no choice, but to leave it for now so he can maintain his cover.
After Hans successfully retrieves the detonators, he gets his P7M13 pistol somehow, probably from Uli since Hans send him to finish setting up the C4 on the roof. Then after learning through the interview of Lucy McClane by reporter Richard Thornburg about hostage Holly Gennero being the wife of McClane, he lets out his pistol and fires up in the ceiling to have the hostages clear out so they can go to the roof and takes Holly to the vault with Eddie, Theo and Kristoff.After McClane knocked out Kristoff and appeared, Hans takes Holly and holds her at gunpoint with the P7M13. After McClane kills Eddie and wounds Hans with a shot to the shoulder, Hans fell out of a window while holding onto Holly. He grabbed onto Holly's watch and tried pulling her out the window with him, while also aiming his P7M13 at John's head. But McClane managed to unclasp the watch, causing Hans to fall off the building to his death with his pistol still in his hand and avenging Joe Takagi and Harry Ellis.
It is unknown what happened to the pistol once Hans hit the ground.