title: using registry to run a prog at startup
body: <p>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</p>
  
  <pre><code>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,&amp;hkey);
  
  if(reg=ERROR_SUCCESS)  
     cout&lt;&lt;"success"&lt;&lt;endl;
  else 
     cout&lt;&lt;"failure"; //(a)
  
  cout&lt;&lt;reg&lt;&lt;endl;  //(b)
  
  if(reg==0)
  {
      RegSetValueEx(hkey,TEXT("key"),0,REG_SZ,(BYTE*)path,strlen(path));
  }
  }
  </code></pre>
  
  <p>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)...</p>