You can't use an output coming from a VGA connection when using Target Display Mode (TDM) on your 27-inch iMac.
The main challenge is that VGA is an analog video signal, and DisplayPort is digital video.
Even if you had standard DVI port on your PC (DVI is a digital video signal), DVI is also not compatible with DisplayPort.
You'll discover that TDM requires either a thunderbolt, or Mini DisplayPort port.
http://support.apple.com/kb/HT3924
That's how it works when connecting Mac to Mac.
I don't know if it will possibly work on your PC - but the only way to find out is to install a graphics card that would give you a DisplayPort output. Some graphics cards could have a Mini DisplayPort, which is the ideal choice - but a DisplayPort to Mini DisplayPort adapter should be OK.
And, then I haven't heard of anyone trying that PC-to-Mac with Target Display Mode. It may not work, even with the correct video output on your PC.
The main challenge is that VGA is an analog video signal, and DisplayPort is digital video.
Even if you had standard DVI port on your PC (DVI is a digital video signal), DVI is also not compatible with DisplayPort.
You'll discover that TDM requires either a thunderbolt, or Mini DisplayPort port.
http://support.apple.com/kb/HT3924
That's how it works when connecting Mac to Mac.
I don't know if it will possibly work on your PC - but the only way to find out is to install a graphics card that would give you a DisplayPort output. Some graphics cards could have a Mini DisplayPort, which is the ideal choice - but a DisplayPort to Mini DisplayPort adapter should be OK.
And, then I haven't heard of anyone trying that PC-to-Mac with Target Display Mode. It may not work, even with the correct video output on your PC.