Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieving Time Zone Info from the Registry

Status
Not open for further replies.

greymonkey

Technical User
Jul 20, 2003
29
0
0
AU
Hi there,

Does any one know a way of retrieving information from the HKEY_LOCAL_MACHINE part of the Registry if you don’t have Admin Rights.

I am trying to get a list of Time Zones and the time offsets from UTC time.

I currently have the code:

Code:
        Dim regKey As RegistryKey
        Const TimeRegAddress As String = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones"
        regKey = Registry.LocalMachine.OpenSubKey(TimeRegAddress, False)

            For Each innerKey As String In regKey.GetSubKeyNames
                Dim tempRegKey As RegistryKey
                tempRegKey = regKey.OpenSubKey(innerKey, True)
                ListBox1.Items.Add(tempRegKey.GetValue("Display"))         
            Next

This retrieves the info ok but only works if you have Admin Rights.


If have seen some code using the advapi32.dll file to access the registry but this all seems to be directed towards VB 6 and does not seem to work with .net 2005.


If any one has any ideas?

Thanks,
 
Do a search in this forum for 'impersonation', and you will find several examples of hoe to run code as another user, including the system administrator.



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
impersonation seems to work if you know an Administrator user id and password but as this will be used on a wide range of workstations and each one has a different Administrators password I cant find away of getting it to work.

Any other ideas how to retrive a list of all Time Zones?

Thanks,

 
If the workstations are on a network, and the Domain Administrator is set to be a member of the Local Administrator's group on the workstation, then impersonating the Domain Admin sould work.

Also, check out this link, it may hace something that can help you:

[URL unfurl="true"]http://www.itworld.com/nl/windows_sec/09232002/[/url]

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top