Login
Buscar
Quem está conectado
Há 5 usuários online :: Nenhum usuário registrado, Nenhum Invisível e 5 Visitantes :: 2 Motores de buscaNenhum
[ Ver toda a lista ]
O recorde de usuários online foi de 71 em 19/7/2010, 11:47
Brasília
| |
Estamos no Twitter

Nossa Comunidade

Nosso Grupo

Últimos assuntos
Top dos mais postadores
| Marcos Guedes | ||||
| hugo | ||||
| alceu11 | ||||
| Julio | ||||
| marcelofazan | ||||
| mfelis | ||||
| cabeludo | ||||
| Tales Ruan | ||||
| Nelson Arcas | ||||
| marcio |
Contagem Regressiva em tela de login
16/7/2010, 11:10 por Linghston
Ola amigos, esta é minha primeira participação neste forum e espero poder encontar aqui ajuda para ...
Comentários: 15
Estatísticas
Temos 926 usuários registradosO último usuário registrado atende pelo nome de Maria Tognetti
Os nossos membros postaram um total de 8596 mensagens em 1239 assuntos
WSH para ler, gravar e excluir chaves do registro
Página 1 de 1 • Compartilhe •
WSH para ler, gravar e excluir chaves do registro
- Código:
WSHShell = CreateObject("WScript.Shell")
*!* Create Registry Keys
- Código:
WSHShell.Popup( "Create key HKCU\MyRegKey with value 'Top level key'")
WSHShell.RegWrite( "HKCU\MyRegKey\", "Top level key")
WSHShell.Popup( "Create key HKCU\MyRegKey\Entry with value 'Second level key'")
WSHShell.RegWrite( "HKCU\MyRegKey\Entry\", "Second level key")
WSHShell.Popup( "Set value HKCU\MyRegKey\Value to REG_SZ 1")
WSHShell.RegWrite ("HKCU\MyRegKey\Value", 1)
WSHShell.Popup( "Set value HKCU\MyRegKey\Entry to REG_DWORD 2")
WSHShell.RegWrite( "HKCU\MyRegKey\Entry", 2, "REG_DWORD")
WSHShell.Popup( "Set value HKCU\MyRegKey\Entry\Value1 to REG_BINARY 3")
WSHShell.RegWrite( "HKCU\MyRegKey\Entry\Value1", 3, "REG_BINARY")
*!* Read Registry Keys
- Código:
lcValue1 = WSHShell.RegRead("HKCU\MyRegKey\")
WSHShell.Popup("Value of HKCU\MyRegKey: " + lcValue1)
lcValue2 = WSHShell.RegRead("HKCU\MyRegKey\Entry\")
WSHShell.Popup("Value of HKCU\MyRegKey\Entry\: " + lcValue2)
lcValue3 = WSHShell.RegRead("HKCU\MyRegKey\Value")
WSHShell.Popup("Value of HKCU\MyRegKey\Value: " + lcValue3)
lnValue1 = WSHShell.RegRead("HKCU\MyRegKey\Entry")
WSHShell.Popup("Value of HKCU\MyRegKey\Entry: " + ALLTRIM(STR(lnValue1)))
lnValue3 = WSHShell.RegRead("HKCU\MyRegKey\Entry\Value1")
WSHShell.Popup("Value of HKCU\MyRegKey\Entry\Value1: " + ALLTRIM(STR(lnValue3(1))))
*!* Delete Registry Keys
- Código:
WSHShell.Popup( "Delete value HKCU\MyRegKey\Entry\Value1")
WSHShell.RegDelete( "HKCU\MyRegKey\Entry\Value1")
WSHShell.Popup ("Delete key HKCU\MyRegKey\Entry")
WSHShell.RegDelete( "HKCU\MyRegKey\Entry\")
WSHShell.Popup ("Delete key HKCU\MyRegKey")
WSHShell.RegDelete( "HKCU\MyRegKey\")
Fonte:
[Você precisa estar registrado e conectado para ver este link.]
_________________
Marcos Guedes - Programador e desenvolvedor Web.
Convidado, seja nosso seguidor no Twitter:
twitter.com/programacaobras

Marcos Guedes- Webmaster

Re: WSH para ler, gravar e excluir chaves do registro
muito bom
_________________
A lingua é o chicote do corpo! Minhas feridas ainda doem!

hugo- Usuário 5 Estrelas

Re: WSH para ler, gravar e excluir chaves do registro
Uma dúvida...
E se eu não tiver a Chave de Registro? pra mim apresenta um erro... como perguntar pro meu sistema se existe essa chave?
E se eu não tiver a Chave de Registro? pra mim apresenta um erro... como perguntar pro meu sistema se existe essa chave?
- Código:
OLE IDispatch exception code 0 from WshShell.RegRead: Raiz Inválida na chave de Registro "Minha chave"...

djguina- Começando a Participar

Re: WSH para ler, gravar e excluir chaves do registro
Veja se este código ajuda:
Fonte:
- [Você precisa estar registrado e conectado para ver este link.]
- Código:
LOCAL lcversion
lcversion = "7.0"
PUBLIC goapp
goapp = CREATEOBJECT('capp')
MESSAGEBOX(goapp.readreg('HLM','Software\Microsoft\VisualFoxpro\' + lcversion +;
'\Registration','ProductID'))
goapp = null
DEFINE CLASS capp AS CONTAINER
*-- Reads the windows Registry.
PROCEDURE readreg
* Start of Code
LPARAMETERS tckey,tcsubkey,tcvalue
IF PCOUNT() = 2
tcvalue = ""
ENDIF
* setup environment
LOCAL nkey, csubkey, cvalue, cvalueread
#DEFINE hkey_users -2147483645
#DEFINE hkey_local_machine -2147483646
#DEFINE hkey_current_user -2147483647
#DEFINE hkey_classes_root -2147483648
DO CASE
CASE m.tckey == "HCR"
nkey = hkey_classes_root
CASE m.tckey == "HLM"
nkey = hkey_local_machine
CASE m.tckey = "HCU"
nkey = hkey_current_user
CASE m.tckey = "HCR"
nkey = hkey_classes_root
OTHERWISE
nkey = m.tckey
ENDCASE
csubkey = m.tcsubkey
cvalue = m.tcvalue
* example 1
* nKey = HKEY_LOCAL_MACHINE
* cSubKey = "Software\VfpRegTest"
* cValue = "TestREG_SZ"
* example 2
* nKey = HKEY_CLASSES_ROOT
* cSubKey = "Spin.SpinButton\CLSID"
* cValue = ""
* here is where we will actually read the registry
cvalueread = THIS.readreg_sz(nkey, csubkey, cvalue)
IF (EMPTY(cvalueread)) THEN
cvalueread = "REGISTRY KEY NOT FOUND"
* MESSAGEBOX("Function Not Successful.") && testing only
ELSE
* MESSAGEBOX("Function Successful. " + cValueRead) && testing only
ENDIF
RETURN cvalueread
ENDPROC
*-- API's used by the ReadReg method.
PROCEDURE readreg_sz
* This function reads a REG_SZ value from the registry. If successful,
* it will return the value read. If not successful, it will return an empty string.
PARAMETERS nkey, csubkey, cvalue
* nKey The root key to open. It can be any of the constants defined below.
* #DEFINE HKEY_CLASSES_ROOT -2147483648
* #DEFINE HKEY_CURRENT_USER -2147483647
* #DEFINE HKEY_LOCAL_MACHINE -2147483646
* #DEFINE HKEY_USERS -2147483645
* cSubKey The SubKey to open.
* cValue The value that is going to be read.
* Constants that are needed for Registry functions
#DEFINE reg_sz 1
* WIN 32 API functions that are used
DECLARE INTEGER RegOpenKey IN Win32API ;
INTEGER nHKey, STRING @cSubKey, INTEGER @nResult
DECLARE INTEGER RegQueryValueEx IN Win32API ;
INTEGER nHKey, STRING lpszValueName, INTEGER dwReserved,;
INTEGER @lpdwType, STRING @lpbData, INTEGER @lpcbData
DECLARE INTEGER RegCloseKey IN Win32API INTEGER nHKey
* Local variables used
LOCAL nerrcode && Error Code returned from Registry functions
LOCAL nkeyhandle && Handle to Key that is opened in the Registry
LOCAL lpdwvaluetype && Type of Value that we are looking for
LOCAL lpbvalue && The data stored in the value
LOCAL lpcbvaluesize && Size of the variable
LOCAL lpdwreserved && Reserved Must be 0
* Initialize the variables
nkeyhandle = 0
lpdwreserved = 0
lpdwvaluetype = reg_sz
lpbvalue = ""
nerrcode = regopenkey(nkey, csubkey, @nkeyhandle)
* If the error code isn't 0, then the key doesn't exist or can't be opened.
IF (nerrcode # 0) THEN
RETURN ""
ENDIF
lpcbvaluesize = 1
* Get the size of the data in the value
nerrcode=regqueryvalueex(nkeyhandle, cvalue, lpdwreserved, @lpdwvaluetype, @lpbvalue, @lpcbvaluesize)
* Make the buffer big enough
lpbvalue = SPACE(lpcbvaluesize)
nerrcode=regqueryvalueex(nkeyhandle, cvalue, lpdwreserved, @lpdwvaluetype, @lpbvalue, @lpcbvaluesize)
=regclosekey(nkeyhandle)
IF (nerrcode # 0) THEN
RETURN ""
ENDIF
lpbvalue = LEFT(lpbvalue, lpcbvaluesize - 1)
RETURN lpbvalue
ENDPROC
ENDDEFINE
Fonte:
- [Você precisa estar registrado e conectado para ver este link.]
_________________
Marcos Guedes - Programador e desenvolvedor Web.
Convidado, seja nosso seguidor no Twitter:
twitter.com/programacaobras

Marcos Guedes- Webmaster

Permissão deste fórum:
Você não pode responder aos tópicos neste fórum





» Gerador randomico de chave/senha VFP
» Help do VFP 9 desapareceu
» Acessos no Programação Brasil
» Niver do Alceu
» Report com comandos de impressão @ SAY
» VFP Studio
» Emulacao de MAC em PC
» Imagem
» Formação em produção de games 3D no Rio de Janeiro
» Trazer para frente uma aplicação em execução
» PictureBox com fundo transparente
» Report so imprime primeiro registro
» IE x VFP
» Aplicativos para Dispositivos moveis
» Problemas com Form MDI
» Dataset ou Datatable
» Desabafo de um idoso!
» Select criando cursor apresenta erro
» Comandos alterados de DOS para Visual