borris83
Member
- Joined
- Apr 30, 2009
- Messages
- 23
- Programming Experience
- Beginner
Hi everyone,
Here is a part of my code which loops through the items in a checkedlistbox.. The text of each item is the name of a computer...
When the loop runs for the first time, it runs fine, but when it goes through the loop the second time I am getting the following exception:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt
The code connects to wmi and retrieves the time zone information from the registry.. It is given below:
So, if the checkedlistbox has only one item checked, the code runs fine... If you check more than one box, it gives problem... any idea?
Here is a part of my code which loops through the items in a checkedlistbox.. The text of each item is the name of a computer...
When the loop runs for the first time, it runs fine, but when it goes through the loop the second time I am getting the following exception:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt
The code connects to wmi and retrieves the time zone information from the registry.. It is given below:
VB.NET:
For Each item As String In checkedListBox1.CheckedItems
strcomputer = item
oreg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strcomputer & "\root\default:StdRegProv")
strkeypath = "System\CurrentControlSet\Control\TimeZoneInformation"
strvaluename = "ActiveTimeBias"
'the below line is the one which creates the problem
[B]oreg.GetDWORDValue(HKEY_LOCAL_MACHINE, strkeypath, strvaluename, dwvalue[/B])
lngTZBias = dwvalue
' then there are lines of code which does something with 'lngTZBias .. That works just fine...
next
So, if the checkedlistbox has only one item checked, the code runs fine... If you check more than one box, it gives problem... any idea?
Last edited by a moderator: