HDC hdc_ = GetDC(GetDesktopWindow()) ; //I'm not sure if this is right or what exactly it does.
cent.x = 500;
cent.y = 500;
centerColor = GetPixel(hdc_, cent.x, cent.y);
ofs << int_var;
cout << GetPixel(hdc_, cent.x, cent.y) << endl;
cout << endl << "information has been transferred. press any key to close...";
1. My code is supposed to find the RGB of a pixel on screen and write the information to the first line of outputs.txt. I don't think it does however. The numbers that appear on the screen are different to what is written in the txt file. For example, the program says 15794175, but the txt file has 4194816 written to it. What have I done wrong or why is it doing this?
2. I ultimately want to write the values of five pixels to the txt file, with each number on a different line. How do I make it so the value is written to the second, third etc line?
It's would be quicker to code by just reading the existing two lines and then writing out the first one along with the new second line.
Otherwise you'd have to open the file for read-write access, seek forward to find the end of the first line, write your new line, and then adjust the position of the end of file (the new file size can be bigger or smaller).