Why so difficult? There's this component called foo_npsimple that dumps that info into a text file, and with a bit of title formatting you can even tell if Foobar is paused or stopped.
here's my formatting script (like the name of the component, it's very simple)
$if(%isplaying%,
$if(%ispaused%,
paused
,
playing
): $if($and(%artist%,%title%),%artist% - %title% )
$if($and(%title%,$not(%artist%)), %title% )
$if(%album%,from the album: %album%[ '('%date%')']),
stopped
)
It updates the info on track change, pause, stop and even every second if you so wish.
PS. there's similar components that sends the info to dedicated clients, so maybe that route is the answer, instead of querying Foobar create a little component that tells your program. Seeing as you're comfortable with Windows Messaging, tackling the FB2K SDK to whip up something for Foobar sending you that info shouldn't be that much of a hurdle?