Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.20 KB | None | 0 0
  1. #include <windows.h>
  2. #include <tchar.h>
  3. #include <io.h>
  4. #include <fcntl.h>
  5. #include <stdio.h>
  6.  
  7. #define TAM 200
  8. #define MAX 256
  9.  
  10. int _tmain(int argc, TCHAR* argv[]) {
  11.     HKEY chave;
  12.     TCHAR chave_nome[TAM], par_nome[TAM], par_valor[TAM], str[MAX], result[2*MAX] = TEXT("Software\\Aula\\");
  13.     /* ... Mais variáveis ... */
  14.  
  15. #ifdef UNICODE
  16.     _setmode(_fileno(stdin), _O_WTEXT);
  17.     _setmode(_fileno(stdout), _O_WTEXT);
  18.     _setmode(_fileno(stderr), _O_WTEXT);
  19. #endif
  20.  
  21.     /* ... as várias alíneas ...*/
  22.     do {
  23.         //_tprintf(result);
  24.         _tprintf(TEXT("\nInsert key: "));
  25.         fflush(stdin);
  26.         _fgetts(str, MAX, stdin);
  27.         //Retirar \n
  28.         str[_tcslen(str) - 1] = '\0';
  29.         _tprintf(TEXT("%s"), str);
  30.         _stprintf_s(result, 2 * MAX, TEXT("Software\\Aula\\%s"), str);
  31.         _tprintf(TEXT("\n%s"), result);
  32.         //_stprintf_s(result, MAX, TEXT("Frase:%s, Tamanho:%d\n"), str, _tcslen(str));
  33.         RegCreateKey(HKEY_CURRENT_USER, result, &chave);
  34.  
  35.         _tprintf(TEXT("\nInsert key: "));
  36.         fflush(stdin);
  37.         _fgetts(par_valor, TAM, stdin);    
  38.         //Retirar \n
  39.         par_valor[_tcslen(par_valor) - 1] = '\0';
  40.  
  41.         RegSetValue(chave, NULL, REG_SZ, par_valor, NULL);
  42.  
  43.  
  44.     } while (_tcsicmp(TEXT("FIM"), str));
  45.  
  46.  
  47.     RegCloseKey(chave);
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement