{"id":1507,"date":"2015-10-17T15:25:04","date_gmt":"2015-10-17T19:25:04","guid":{"rendered":"http:\/\/linguagemprisma.net\/blog\/?p=1507"},"modified":"2015-10-17T15:47:48","modified_gmt":"2015-10-17T19:47:48","slug":"registro-do-windows-enumerando-chaves-e-valores","status":"publish","type":"post","link":"https:\/\/linguagemprisma.br4.biz\/blog\/win\/registro-do-windows-enumerando-chaves-e-valores\/","title":{"rendered":"Registro do Windows ( Enumerando chaves e valores)"},"content":{"rendered":"<p>Esse exemplo demonstrar\u00e1 como enumerar (listar) chaves, nomes ou valores.<\/p>\n<p>Extremamente importante se voc\u00ea quer fazer uma fun\u00e7\u00e3o de pesquisa no registro.<\/p>\n<p>Segue o c\u00f3digo comentado:<\/p>\n<pre class=\"lang:prisma decode:true\">inclua'win';\r\n\r\nk = win.RegAbraChave( HKEY_CURRENT_USER,'PrismaInfo', KEY_LEITURA);\r\n\r\n\r\n\/\/enumerando os nomes da chave 'k' : \"HKEY_CURRENT_USER\\\\PrismaInfo\\\\\"\r\nv = win.RegEnumere( k )\r\n\r\n\r\nse v entao \r\n    \/\/lendo os valores\r\n    para i , v em ipares( v ) inicio\r\n      imprima(v);\r\n      \r\n      \r\n      \/\/obtendo informacao de tipo de chave e valor, e tamanho: (retorno \u00e9 uma tabela com os campos: tipo , tamanho\r\n      local t = win.RegObtInfoValor(k , v )\r\n      \r\n      imprima( 'tamanho: ' .. t.tamanho);\r\n      \r\n      se t.tipo == REG_BINARY entao imprima('\\n'.. t.tipo , 'tipo binario')\r\n      imprima( desempacote(win.RegLeiaChaveBin(k,v) ) );\r\n      senaose t.tipo == REG_SZ entao imprima('\\n'.. t.tipo , 'tipo string')\r\n      imprima( win.RegLeiaChaveStr(k,v) );\r\n      senaose t.tipo == REG_EXPAND_SZ entao imprima( '\\n'.. t.tipo , 'tipo string com variaveis de ambiente')\r\n      imprima( win.RegLeiaChaveStr(k,v) );\r\n      senaose t.tipo == REG_MULTI_SZ entao imprima( '\\n'.. t.tipo , 'tipo multi string')\r\n      local tt = win.RegLeiaChaveStr(k,v) ;\r\n      imprima( desempacote(tt) );\r\n      senaose t.tipo == REG_DWORD entao imprima('\\n'.. t.tipo , 'tipo numero')\r\n      imprima( win.RegLeiaChaveNum(k,v) );\r\n      fim\r\n      \r\n      \r\n    fim \/\/fim para\r\n    imprima( v.tipo );\r\n    \r\n    \r\n    \r\n    \r\nfim\r\n\r\n\r\n\r\n\r\nwin.RegFecheChave(k);\r\n\r\nwin.poe'Ok para sair';\r\n<\/pre>\n<p>Detalhes:<\/p>\n<p>A fun\u00e7\u00e3o para listar todas as subchaves de uma chave maior \u00e9:<\/p>\n<pre class=\"lang:prisma decode:true\">v = win.RegEnumere( k )<\/pre>\n<p>Onde<strong> &#8216;k&#8217;<\/strong> \u00e9 a chave aberta anteriormente.<\/p>\n<p><strong>O retorno \u00e9 uma tabela Prisma<\/strong> em que cada \u00edndice (elemento da matriz) \u00e9 uma string contendo o nome da subchave ou do valor listado.<\/p>\n<p>Outra fun\u00e7\u00e3o interessante aqui \u00e9:<\/p>\n<pre class=\"lang:prisma decode:true\">local t = win.RegObtInfoValor(k , v )<\/pre>\n<p>em que <strong>&#8216;k&#8217; <\/strong>\u00e9 a chave aberta anteriormente. E <strong>&#8216;v&#8217; <\/strong>\u00e9 o nome da subchave ou valor contida na chave aberta <strong>&#8216;k&#8217;;<\/strong><\/p>\n<p><strong>O retorno \u00e9 uma tabela<\/strong> contendo os campos: .tipo = tipo de dado, e .tamanho = tamanho (bytes de um n\u00famero, ou caracteres de uma string). Com isso \u00e9 poss\u00edvel saber que tipo de dado est\u00e1 gravado na chave ou nome de valor listado.<\/p>\n<p>At\u00e9 mais, qualquer coisa n\u00e3o deixe de comentar aqui ou no <a href=\"http:\/\/linguagemprisma.net\/prisma_forum\" target=\"_blank\">f\u00f3rum oficial.<\/a><\/p>\n<p>Att. Adalberto Amorim Felipe.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Esse exemplo demonstrar\u00e1 como enumerar (listar) chaves, nomes ou valores. Extremamente importante se voc\u00ea quer fazer uma fun\u00e7\u00e3o de pesquisa no registro. Segue o c\u00f3digo comentado: inclua&#8217;win&#8217;; k = win.RegAbraChave( HKEY_CURRENT_USER,&#8217;PrismaInfo&#8217;, KEY_LEITURA); \/\/enumerando os nomes da chave &#8216;k&#8217; : &#8220;HKEY_CURRENT_USER\\\\PrismaInfo\\\\&#8221; v = win.RegEnumere( k ) se v entao \/\/lendo os valores para i , v&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-1507","post","type-post","status-publish","format-standard","hentry","category-win"],"_links":{"self":[{"href":"https:\/\/linguagemprisma.br4.biz\/blog\/wp-json\/wp\/v2\/posts\/1507","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linguagemprisma.br4.biz\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linguagemprisma.br4.biz\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linguagemprisma.br4.biz\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linguagemprisma.br4.biz\/blog\/wp-json\/wp\/v2\/comments?post=1507"}],"version-history":[{"count":4,"href":"https:\/\/linguagemprisma.br4.biz\/blog\/wp-json\/wp\/v2\/posts\/1507\/revisions"}],"predecessor-version":[{"id":1513,"href":"https:\/\/linguagemprisma.br4.biz\/blog\/wp-json\/wp\/v2\/posts\/1507\/revisions\/1513"}],"wp:attachment":[{"href":"https:\/\/linguagemprisma.br4.biz\/blog\/wp-json\/wp\/v2\/media?parent=1507"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linguagemprisma.br4.biz\/blog\/wp-json\/wp\/v2\/categories?post=1507"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linguagemprisma.br4.biz\/blog\/wp-json\/wp\/v2\/tags?post=1507"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}