char buffer issue in windows7 machines

  c++, mfc, visual-c++, win32com

I have an issue with char buffer in windows7 machine.
Previously we are using char buffer like this char_256 [256], now we have upgraded/created the char buffer with 512 and 1024 i.e char_512 [512], char_1024 [1024].

512 and 1024 are working fine in windows 10, server12,16,19 machines, it is not working/application crashing in windows7 machines, and i tried below code still not working, anyone can suggest to me how to achieve this.

char_256 buffer
char_1024 buffer

My question is like, how to find out the os version at compile time and based on that is has to take the proper char buffer at runtime (i.e if win7 it has to take char[256], if it is win10 or latest it has to take char[512], char[1024]).

Note: Need the solution in c/win32.

Source: Windows Questions C++