When I run this code in the place where it was to appear the directory appears Ó²o \ formula.exe , could someone help me solve?
#include <iostream>
#include <Windows.h>
#include <lmcons.h>
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <string>
using namespace std;
string teste() {
char buffer[MAX_PATH];
GetModuleFileName( NULL, buffer, MAX_PATH );
string::size_type pos = string( buffer ).find_last_of( "\/" );
return string( buffer ).substr( 0, pos);
}
int main(){
TCHAR teste[MAX_PATH];
cout << teste << endl;
string cmd = "reg add HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run /t REG_SZ /v formula /d ";
cmd += teste;
cmd += "\formula.exe";
cout << cmd.c_str() << endl;
system(cmd.c_str());
}