Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How can I show the value of a DWORD

Posted on 2009-07-11
14
Medium Priority
?
355 Views
Last Modified: 2012-05-07
when u go into registry and right click a reg dword file and choose modify i can see the value data, how do check that info using delphi to say if for example DWORD value is 1 it will come back and say yes  and if it is 0 it will no when the user presses a button on my delphi application?
0
Comment
Question by:SonicM3
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 7
14 Comments
 
LVL 6

Expert Comment

by:FactorB
ID: 24830357
Something like this

Uses
Registry;

procedure TForm1.Button1Click(Sender: TObject);
var
reg:tregistry;
begin
reg:=Tregistry.Create;
try
reg.RootKey:=HKEY_LOCAL_MACHINE;
reg.OpenKey('\SOFTWARE\Microsoft\Windows\CurrentVersion\',false);
if reg.ValueExists('Some_Value') then begin
if reg.ReadString ('Some_Value')='1' then Button1.Caption:='Yes';
if reg.ReadString ('Some_Value')='0' then Button1.Caption:='No';
end;
finally
reg.Free;
end;
0
 
LVL 6

Expert Comment

by:FactorB
ID: 24830365
Shortage of ends:) put above one more ... end;
0
 

Author Comment

by:SonicM3
ID: 24830394
ah thanks man, i am so close can you just finish this off.

i want to go to ... currentversion/polices/system/enablelua   and show if 1 is on that yeh admin rights limited access and if its 0 the admin rights have full access
just nearly got it sorted.
how do i edit the code to do this?

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:SonicM3
ID: 24830403
edit:

just to confirm this is a dword and here is the location and valves.

test5.jpg
0
 
LVL 6

Expert Comment

by:FactorB
ID: 24830408
Uses
Registry;

procedure TForm1.Button1Click(Sender: TObject);
var
reg:tregistry;
begin
reg:=Tregistry.Create;
try
reg.RootKey:=HKEY_LOCAL_MACHINE;
reg.OpenKey('\SOFTWARE\Microsoft\Windows\CurrentVersion\polices\system\',false);
if reg.ValueExists('enablelua') then begin
if reg.ReadString ('enablelua')='1' then Button1.Caption:='Yes';
if reg.ReadString ('enablelua')='0' then Button1.Caption:='No';
end;
finally
reg.Free;
end;
end;
0
 

Author Comment

by:SonicM3
ID: 24830414
This works fine for strings but does not seem to work for DWORD.
0
 
LVL 6

Accepted Solution

by:
FactorB earned 2000 total points
ID: 24830445
Sorry typo polices instead of policies and I should use integer for DWord

procedure TForm1.Button1Click(Sender: TObject);
var
reg:tregistry;
begin
reg:=Tregistry.Create;
try
reg.RootKey:=HKEY_LOCAL_MACHINE;
reg.OpenKey('\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system\',false);
if reg.ValueExists('EnableLUA') then begin
if reg.ReadInteger ('EnableLUA')=1 then Button1.Caption:='Yes';
if reg.ReadInteger ('EnableLUA')=0 then Button1.Caption:='No';
end;
finally
reg.Free;
end;
end;
0
 

Author Comment

by:SonicM3
ID: 24830477
well done mate, top marks!  
I will award you points for that but can i ask a quick question.

at the moment i can read fine and i am an admin on limted access basically with lua on, how can i change the 1 to a 0 to turn lua off and give me fulll access.
Like i say point rewarded anyways for the other answer excellent!
0
 
LVL 6

Expert Comment

by:FactorB
ID: 24830500
You are more than welcome to ask, add

reg.WriteInteger('EnableLUA',0);

to the code

procedure TForm1.Button1Click(Sender: TObject);
var
reg:tregistry;
begin
reg:=Tregistry.Create;
try
reg.RootKey:=HKEY_LOCAL_MACHINE;
reg.OpenKey('\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system\',false);
if reg.ValueExists('EnableLUA') then begin
reg.WriteInteger('EnableLUA',0);
if reg.ReadInteger ('EnableLUA')=1 then Button1.Caption:='Yes';
if reg.ReadInteger ('EnableLUA')=0 then Button1.Caption:='No';
end;
finally
reg.Free;
end;
end;

Regards,
B.
0
 

Author Comment

by:SonicM3
ID: 24830555
super!  I will add this after lunch.
thanks again
0
 

Author Comment

by:SonicM3
ID: 24830777
can you help me figure out why the things dont show?
like.. when i select the button it shows label1 but nothing else, when im logged in as (1) and when im logged in as (0) nothing works..

its like,none of the commands work for the options switch.


procedure TForm1.Button1Click(Sender: TObject);

  var
reg:tregistry;
begin
reg:=Tregistry.Create;
try
reg.RootKey:=HKEY_LOCAL_MACHINE;
reg.OpenKey('\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system\',false);
if reg.ValueExists('EnableLUA') then begin
if reg.ReadInteger ('EnableLUA')=0
then
label1.show;
button2.show;
button3.show;


if reg.ReadInteger ('EnableLUA')=1 then
 label2.Show;
 button4.show;
 button5.show;

     end;
finally
reg.Free;
end;
end;
0
 
LVL 6

Expert Comment

by:FactorB
ID: 24830798
Try this:

procedure TForm1.Button1Click(Sender: TObject);

var
reg:tregistry;
begin
reg:=Tregistry.Create;
try
reg.RootKey:=HKEY_LOCAL_MACHINE;
reg.OpenKey('\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system\',false);
if reg.ValueExists('EnableLUA') then begin
 if reg.ReadInteger ('EnableLUA')=0 then begin
  label1.visible:=true;
  button2.visible:=true;
  button3.visible:=true;
 end;
 if reg.ReadInteger ('EnableLUA')=1 then begin
  label2.visible:=true;
  button4.visible:=true;
  button5.visible:=true;
 end;
end;
finally
reg.Free;
end;
end;
0
 

Author Comment

by:SonicM3
ID: 24830865
ur the man!
cheers mate, i just really want to thank you for your help with this stuff. Thankyou so much. If i need another Q, ill make a new topic and give ya more points mate.

cheers
0
 
LVL 6

Expert Comment

by:FactorB
ID: 24830952
Don't worry I am glad that your code is working.
Just...keep typing. :)

Have a good day,
B.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question