-1
Guys, my question is how to put string1 from a function strcat(string1,string3);
within a string of grabbing windows code user name:system("reg add HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Run /t REG_SZ /v NOME_DO_SEU_PROGRAMA /d $string1");
#include <iostream>
#include <cstdio>
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main()
{
//pegando usuario do windows
//WINBASEAPI BOOL WINAPI GetUserNameA (LPSTR,PDWORD);
//WINBASEAPI BOOL WINAPI GetUserNameW(LPWSTR,PDWORD);
char acUserName[100];
char destino11[100];
DWORD nUserName = sizeof(acUserName);
char destino[200];
if (GetUserName(acUserName, &nUserName)) {
}
//movendo
int ret;
char oldname[] = "config/config.exe";
char string1[] = "C:\\Users\\";
strcat(string1,acUserName);
char string3[] = "\\Searches\\config.exe";
strcat(string1,string3);
ret = rename(oldname, string1);
if(ret == 0) {
printf("File renamed successfully");
} else {
printf("Error: unable to rename the file");
}
//ADICIONAR REGISTRO AQUI AQUI COMO COLOCAR A VARIAVEL STRING1 AI DENTRO DO SYSTEM???
system("reg add HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Run /t REG_SZ /v NOME_DO_SEU_PROGRAMA /d $string1");
return 0;
system("pause");
}
people? Someone can help me?
– Mayara Rabelo
if you already have both strings ready, how difficult it is to use strcpy to copy and strcat to concatenate?
– Murilo Portugal