Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 888049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:19:52+00:00 2026-05-15T13:19:52+00:00

hi I have to write a windows api code that encrypts a file by

  • 0

hi I have to write a windows api code that encrypts a file by adding three to each character.

so I wrote this now its not doing anything … where i go wronge

    #include "stdafx.h"
    #include <windows.h>

int _tmain(int argc, _TCHAR* argv[])
{
    HANDLE filein,fileout;

    filein=CreateFile
    (L"d:\\test.txt",GENERIC_READ,0,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);

    fileout=CreateFile
    (L"d:\\test.txt",GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);

    DWORD really; //later this will be used to store how many bytes I succeed to read
    do
    {
        BYTE x[1024];  //the buffer the thing Im using to read in
        ReadFile(filein,x,1024,&really,NULL);

        for(int i=0 ; i<really ; i++)
        {
            x[i]= (x[i]+3) % 256; 
        }

        DWORD really2;
        WriteFile(fileout,x,really,&really2,NULL);

    }while(really==1024);

    CloseHandle(filein);
    CloseHandle(fileout);

    return 0;
}

and if Im right how can i know its ok

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T13:19:52+00:00Added an answer on May 15, 2026 at 1:19 pm

    First, you can’t overwrite a file that’s in use. You will need to use different pathnames for your input and output, and then rename files at the end.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program I wrote in Windows with this piece of code that
I have to write a tool, that uses the IIS7 Managed Code Administration API.
I have some text to write to the Windows console that I need to
I have some code that requests some JSON from an API. When data is
Occasionally I'll have some WPF C# code that I'd like to write in a
I have to write a code such that, it may create child process via
I have C function prototypes (certain windows api header files) that look like: int
I have a mobile platform that I am trying to write some communications code
I'm about to write code for Windows that has somewhat similar functionality to the
Imagine you are on Windows 7 and you have to write a GUI for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.