regedit rule c++

Hi i use my application a lot of time so i want to start when i start my window. But i have a problem, i'm trying a simple example to create a regedit rule. And i want to include the path of file i'm running. I tried this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include "stdafx.h"
#include <iostream>
#include <windows.h>

int main()
{
    HKEY * key;
    LPCTSTR ruta = TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\");
    long status = RegOpenKey(HKEY_LOCAL_MACHINE, ruta, key);
    string valor;
    string subclave;
    LPCTSTR _subclave = TEXT(subclave.c_str());
    LPCTSTR _valor = TEXT(valor.c_str());
    long crear = RegSetValueEx(*key, _subclave, 0, REG_SZ, (LPBYTE)_valor, strlen(_valor) * sizeof(char));
    return 0;
}


But still show me errors. I'm trying to do because i want to do easy example to create one rule in my regedit and take the path of my file that i run. and put like value. I'm using visual studio 2015 like ide
Last edited on
Topic archived. No new replies allowed.