I know that CryptProtectData function crypts data using windows user\'s password, I can decrypt it using CryptUnprotectData function when I am logged in crypter user, how is
CryptProtectData can use the CRYPTPROTECT_LOCAL_MACHINE flag, but that means any user will decrypt. Using CRYPTPROTECT_LOCAL_MACHINE basically does not protect anything at the user level, it simply makes the data protected on machine level (and even so, an user with a roaming profile can decrypt as well). If you need to protect something only with password, consider using CryptGenKey and CryptEncrypt functions instead (samples provided at the bottom of the page for both encrypting and decrypting a file).