If you have LabVIEW Full or Pro, you can use the Harmonic Distortion Analyzer VI from the Signal Processing>>Waveform Measurements palette.
If you also have the LabVIEW Sound and Vibration Toolkit, use the SVT THD and Harmonic Components VI from the Sound and Vibration>>Distortion palette.
Both of these VIs will correctly identify the fundamental frequency (even when the frequency is not on bin). You should still expect to find harmonics at multiples of the frequency of the fundamental. Once you have identified the fundamental and the harmonics of interest, the power in each component can be computed from the power in the spectral bins closest to each component. Generally, using just the magnitude of the highest bin is prone to errors when the frequencies are not exactly on bin.
I am curious as to why the signal peaks at 985 Hz. Did you mean 975 Hz as this is the nearest bin frequency? Is 985 close enough to 1000? Your post indicated that the input signal is a 1000 Hz sine wave. What causes the shift in frequency? If this is not expected, you might want to double check your array indexing.
I recommend that you use one of the two measurement VIs provided by National Instruments. If you are intent on reimplementing this measurement, I recommend that you test your measurement with various simulated test signals (on bin, off bin, low noise, high noise, etc.).
Doug
Enthusiast for LabVIEW, DAQmx, and Sound and Vibration