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

  • SEARCH
  • Home
  • 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 6554599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:43:09+00:00 2026-05-25T12:43:09+00:00

i am trying to run a code in c++ which will result in an

  • 0

i am trying to run a code in c++ which will result in an .exe file running at startup using registry…but the problem is that the code results fails without showing any errors…i compiled the code in devcpp…
the code is

void createkey(char *path)
{
int reg;
HKEY hkey,Hkey1;
DWORD ptr;

reg=RegOpenKeyEx(HKEY_LOCAL_MACHINE,TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"),0,KEY_SET_VALUE,&hkey);

if(reg=ERROR_SUCCESS)  
   cout<<"success"<<endl;
else 
   cout<<"failure"; //(a)

cout<<reg<<endl;  //(b)

if(reg==0)
{
    RegSetValueEx(hkey,TEXT("key"),0,REG_SZ,(BYTE*)path,strlen(path));
}
}

in the command line failure and 0 got printed as a result of (a) and (b)…(dont know how as the two mean completely opposite things )….the char *path passed to regsetvalueex was “c:/Dev-Cpp/bin/Untitled2.exe”…i am sure that the functions are not working as key doesnt appear in run key(i checked using regedit)…

  • 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-25T12:43:11+00:00Added an answer on May 25, 2026 at 12:43 pm
    if(reg=ERROR_SUCCESS) 
    

    That’s an assignment, you need to use the == operator. Most modern compilers warn about this, be sure to update yours. You probably got an access denied error, can’t write to HKLM\Software without elevation.

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

Sidebar

Related Questions

I am trying to run the code below but it keeps locking up my
I'm trying to run the below-mentioned code in VB(Excel Macro) but I'm stuck with
I'm trying to run a 3d array but the code just crashes in windows
I am trying to write a class that will calculate checksums using multiple processes,
I'm trying to run a webmethod via a jQuery which will query an SQL
Problem I am trying to build a small ruby script - which will be
I'm trying to write a parser using Parsec that will parse literate Haskell files,
I'm trying to run this code: let coins = [50, 25, 10, 5, 2,1]
I am trying to run this code: ItemTaxonomy iTaxonomy = from itemTaxonomy in connection.ItemTaxonomy
I am getting an error while trying to run CFmx code on a remote

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.