Dar acesso todos chave regedit especifica

14/02/2019

0

Boa tarde programadores,
Sou novo na área e iniciante em Delphi e estou querendo aplicar um exemplo de código que peguei aqui no fórum para alterar a permissão de uma chave do registro do windows dando permissão a todos a ela mas não estou sabendo usar direito e queria ajuda de vocês..segue o codigo;

var
eia: TSIDIdentifierAuthority;
pEveryoneSID : PSID;
sd: Windows.TSecurityDescriptor;
pDacl: PACL;
dwAclSize: DWORD;
aHKey: HKEY;
lRetCode: LongInt;
begin
eia.Value[0] := 0;
eia.Value[1] := 0;
eia.Value[2] := 0;
eia.Value[3] := 0;
eia.Value[4] := 0;
eia.Value[5] := SECURITY_WORLD_SID_AUTHORITY;
pEveryoneSID := 0;
pDacl := nil;
lRetCode := RegOpenKeyEx(HKEY_LOCAL_MACHINE, ''''SYSTEM\\\\\\\\CurrentControlSet\\\\\\\\Hardware Profiles\\\\\\\\0001\\\\\\\\Software\\\\\\\\SistemaPDF'''', 0, WRITE_DAC, aHKey);
AllocateAndInitializeSID(eia, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, pEveryoneSid);
dwAclSize := sizeof(TACL) + 2 * ( sizeof(Access_Allowed_ACE) - sizeof(DWORD) ) + GetLengthSid(pEveryoneSid);

pDacl := PACL(HeapAlloc(GetProcessHeap(), 0, dwAclSize));

InitializeAcl(pDacl, dwAclSize,ACL_REVISION);

AddAccessAllowedAce(pDacl, ACL_REVISION, KEY_ALL_ACCESS, pEveryoneSid);

InitializeSecurityDescriptor(@sd, SECURITY_DESCRIPTOR_REVISION);

SetSecurityDescriptorDacl(@sd, TRUE, pDacl, FALSE);

lRetCode := RegSetKeySecurity(aHKey, SECURITY_INFORMATION(DACL_SECURITY_INFORMATION), @sd);

if (lRetCode <> ERROR_SUCCESS) then
ShowMessage (''''Falha ao atribuir permissão a chave de registro!'''')

else
ShowMessage(''''Permissão a chave de registro concluida com exito!'''');
end;

Erros delphi me passa;
(42): E2010 Incompatible types: ''''Byte'''' and ''''_SID_IDENTIFIER_AUTHORITY''''
(43): W1013 Constant 0 converted to NIL
(46): E2010 Incompatible types: ''''PSID_IDENTIFIER_AUTHORITY'''' and ''''_SID_IDENTIFIER_AUTHORITY''''

agradeço quem poder me ajudar...
obrigado.
Jorgeneves338

Jorgeneves338

Responder

Posts

18/02/2019

Jorgeneves338

Boa tarde programadores,
Sou novo na área e iniciante em Delphi e estou querendo aplicar um exemplo de código que peguei aqui no fórum para alterar a permissão de uma chave do registro do windows dando permissão a todos a ela mas não estou sabendo usar direito e queria ajuda de vocês..segue o codigo;

var
eia: TSIDIdentifierAuthority;
pEveryoneSID : PSID;
sd: Windows.TSecurityDescriptor;
pDacl: PACL;
dwAclSize: DWORD;
aHKey: HKEY;
lRetCode: LongInt;
begin
eia.Value[0] := 0;
eia.Value[1] := 0;
eia.Value[2] := 0;
eia.Value[3] := 0;
eia.Value[4] := 0;
eia.Value[5] := SECURITY_WORLD_SID_AUTHORITY;
pEveryoneSID := 0;
pDacl := nil;
lRetCode := RegOpenKeyEx(HKEY_LOCAL_MACHINE, ''''SYSTEM\\\\\\\\\\\\\\\\CurrentControlSet\\\\\\\\\\\\\\\\Hardware Profiles\\\\\\\\\\\\\\\\0001\\\\\\\\\\\\\\\\Software\\\\\\\\\\\\\\\\SistemaPDF'''', 0, WRITE_DAC, aHKey);
AllocateAndInitializeSID(eia, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, pEveryoneSid);
dwAclSize := sizeof(TACL) + 2 * ( sizeof(Access_Allowed_ACE) - sizeof(DWORD) ) + GetLengthSid(pEveryoneSid);

pDacl := PACL(HeapAlloc(GetProcessHeap(), 0, dwAclSize));

InitializeAcl(pDacl, dwAclSize,ACL_REVISION);

AddAccessAllowedAce(pDacl, ACL_REVISION, KEY_ALL_ACCESS, pEveryoneSid);

InitializeSecurityDescriptor(@sd, SECURITY_DESCRIPTOR_REVISION);

SetSecurityDescriptorDacl(@sd, TRUE, pDacl, FALSE);

lRetCode := RegSetKeySecurity(aHKey, SECURITY_INFORMATION(DACL_SECURITY_INFORMATION), @sd);

if (lRetCode <> ERROR_SUCCESS) then
ShowMessage (''''Falha ao atribuir permissão a chave de registro!'''')

else
ShowMessage(''''Permissão a chave de registro concluida com exito!'''');
end;

Erros delphi me passa;
(42): E2010 Incompatible types: ''''Byte'''' and ''''_SID_IDENTIFIER_AUTHORITY''''
(43): W1013 Constant 0 converted to NIL
(46): E2010 Incompatible types: ''''PSID_IDENTIFIER_AUTHORITY'''' and ''''_SID_IDENTIFIER_AUTHORITY''''

agradeço quem poder me ajudar...
obrigado.


ninguém pessoal para me ajudar !!!!!
Responder

Que tal ter acesso a um e-book gratuito que vai te ajudar muito nesse momento decisivo?

Ver ebook

Recomendado pra quem ainda não iniciou o estudos.

Eu quero
Ver ebook

Recomendado para quem está passando por dificuldades nessa etapa inicial

Eu quero

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar