You can control the archive file attribute flag using the ATTRIB
command line or the underlying Windows API (e.g. allowing "your code" full control of the flag). However, when a file is modified the archive flag is set. That is not something you have to do in your application or code. The expected usage scenario is this:
The operating system will set the flag when a file is created or modified
The backup application (e.g. "your code") will reset the flag when a file has been backed up
However, relying on the archive flag for backup can be problematic because multiple independent backup applications may be using the flag.