By exploiting some stupidity or vulnerability in a service running on the computer.
I.e. the computer is acting as a server. This is actually less likely on a Windows PC, as home versions are set up as content consumers, not creators or servers.
By stupidity I mean things like having a root password of "root" and an open telnet port. I thought such things only occurred in the distant past but found an ARM development kit with that only a few weeks ago. Apparently there are a lot of modems and routers based on this and there's a worm which will find them in a few hours/days.
Sometimes a service, or even the operating system itself, is vulnerable to an exploit - typically sending some "illegal" data value that the designers did not allow for. Some years ago I was bitten by a vulnerability in RealNetworks media server, then running as root, and before that millions of systems were vulnerable to the "ping of death" - an illegally-long ICMP data packet. Modern systems are generally proof against such things, and services usually run as a non-privileged ID which limits the possible damage.
There are also application-level attacks such as SQL injection or cross-site scripting attacks against badly configured webservers, password-guessing dictionary attacks against e.g. SSH (don't use "12345" or "letmein" as a password, and don't allow root password logins at all), and denial-of-service attacks trying to overwhelm the network capacity of the system.
Having said all that, there's not a lot of extra danger in someone knowing your ip address. Your machine will be found anyway by scanners, if it's on the public internet (not behind a firewall or NAT), as there are only so many IPv4 addresses and hackers try them all.