Solved

How do I convert a string to a Hex?

Posted on 2006-11-21
7
713 Views
Last Modified: 2008-02-01
How do I convert the "disabled" to hex so I can & it with UF_ACCOUNTDISABLE))?  Thanks

int UF_ACCOUNTDISABLE = 0x2;
string disabled = deChild.Properties["userAccountControl"].Value.ToString();

          if ((disabled.ToString("X2")) & (UF_ACCOUNTDISABLE))
0
Comment
Question by:lapucca
[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
  • 4
  • 3
7 Comments
 
LVL 7

Expert Comment

by:Mohamed Zedan
ID: 17990830
what type is the value in
deChild.Properties["userAccountControl"].Value ?
0
 

Author Comment

by:lapucca
ID: 17990939
I'm trying to determin if the account is disabled.  Would that make the end result 1 or 0?  Thanks.
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

Author Comment

by:lapucca
ID: 17991023
Following the example on http://msdn2.microsoft.com/en-us/library/ms180916.aspx

My following code is getting me an error.  How can I correct this?  Thanks.

Error      2      Cannot implicitly convert type 'int' to 'bool'      C:\Projects\UnityAdmin\Main.cs      821


int disabled = (int)deChild.Properties["userAccountControl"].Value;
if ((disabled) & (UF_ACCOUNTDISABLE))//if disable then use the disabled icon
    newLvNode = NodeDetail.Items.Add
        (new ListViewItem(new string[] { commonName, os, osVersion }, 2));
else
    newLvNode = NodeDetail.Items.Add
        (new ListViewItem(new string[] { commonName, os, osVersion }, 11));
0
 
LVL 7

Expert Comment

by:Mohamed Zedan
ID: 17991107
I believe that the if statement you want should be this...

int UF_ACCOUNTDISABLE = 0x2;
bool disabled = (deChild.Properties["userAccountControl"].Value & UF_ACCOUNTDISABLE == UF_ACCOUNTDISABLE);

          if (disabled)
          {
          }
0
 
LVL 7

Accepted Solution

by:
Mohamed Zedan earned 500 total points
ID: 17991122
I believe that the if statement you want should be this...


int UF_ACCOUNTDISABLE = 0x2;
bool disabled = ((deChild.Properties["userAccountControl"].Value & UF_ACCOUNTDISABLE) == UF_ACCOUNTDISABLE);
//forgot these    ^                                                                                                       ^
          if (disabled)
          {
          }
0
 
LVL 7

Expert Comment

by:Mohamed Zedan
ID: 17991199
If it gives you an error please send it here... and try this next

int UF_ACCOUNTDISABLE = 0x2;
bool disabled = (((int)deChild.Properties["userAccountControl"].Value & UF_ACCOUNTDISABLE) == UF_ACCOUNTDISABLE);

          if (disabled)
          {
          }
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

724 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