So the main sources are either EA's store (Origin/EA Play) or third-party retailers. If EA still sells the game, they can buy it there. If not, then third-party options are the way, but with a warning.
Another angle: Some platforms might have republished the game. For example, GOG.com (formerly Good Old Games) might have it if it's a retro release. But I don't recall GOG ever having that title. Let me check. A quick search on GOG for Half-Blood Prince shows that they do have some Harry Potter games for PS2, but not the PC version. So probably not there. Harry Potter And The Half Blood Prince Cd Key
Another point: The game might be available as a "Classic" title on platforms like EA Play (which is similar to Xbox Game Pass for EA games). So perhaps a subscription could work. Let me check EA Play. Yes, EA Play includes a library of games, which might include Half-Blood Prince if it's part of their catalog. If that's the case, then instead of a CD key, you just install it from the Origin app once subscribed. So the main sources are either EA's store