I've been thinking about this problem recently and it really doesn't seem like it's possible, but I figured that I'd ask just in case.
Assume a simple program, in pseudocode:
run hash on an executable we think is mimicing the true executable check the value against the hash that's hard coded into this executable if it matches, do x if not, do y
In theory it should be quite secure, since only the true executable would be able to produce the same hash that's coded into the executable, but the minute that hash is compiled into that executable the hash would change.
Do you think it's even possible to hard code the resulting hash in any realistic way?
On to the question that has a more likely answer; what would be the most secure way to make sure that an executable is in fact the same executable that was distributed with a program and not some impostor executable trying to hijack the system?