Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads
Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads
Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads
Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads
Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads
Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads
Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads
Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads
Go Back  Xtreme Visual Basic Talk > > > Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads


Reply
 
Thread Tools Display Modes
  #1  
Old 01-21-2012, 01:53 PM
QuickBooksDev QuickBooksDev is offline
Newcomer
 
Join Date: Jun 2010
Posts: 6
Default Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads


I have several programs that must write to HKLM in XP and Windows 7/64 Pro.

The programs work in VB6 but not in VB.Net 2008 on target machines. It does works on our development machine.
Same exact windows.
User is an Administrator.
NOT using Run as.

Both programs are using the same function
Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" _
(ByVal lngRootKey As Long, ByVal lpSubKey As String, phkResult As Long)
As Long
Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" _
(ByVal lngRootKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
etc.

for VB6

Changed Long to Integer for VB.NET

It works on the developement machine

VB6 works on BOTH machines.

VB.Net gets no data reading and err 5 trying to write.

On our development machine and also on the target machine the VB6 registry entry goes to
HKEY_CURRENT_USER\Software\Classes\VirtueSTore\Software\Wow6432Node\.. .

I just cannot figure out why VB6 works but .net doesn't and fails only on the target machine not the development machine.

Thanks
Reply With Quote
  #2  
Old 01-22-2012, 05:33 AM
QuickBooksDev QuickBooksDev is offline
Newcomer
 
Join Date: Jun 2010
Posts: 6
Default

Seems to be related to User Access Control.

If I set to the lowest (Turn off) which is how our development machine was setup the .net program can access the key created by VB6 before it just got nothing.

With it off the .net program acts just as VB6. With it even up 1 notch it does not work at all. Apparently .Net uses the UAC and VB6 does not.
Reply With Quote
  #3  
Old 01-22-2012, 02:44 PM
jantje jantje is offline
Junior Contributor
 
Join Date: Dec 2004
Posts: 255
Default

It's because you are violating the rules. By default .NET puts a manifest along with your app telling the OS it's 'aware' of the rules. When you are writing or reading somewhere your app isn't allowed to read/write, it will generate an exception and thus the error occurs.

For compatibility Microsoft introduced the feature your app can tell the OS it is aware of the new rules, so when an app isn't aware it will tell the app everything went ok and for example your changes are written to the disk or registry.
But in fact it writes to the virtualstore in your own local folder.
The next time you run your app it will read from there and any further changes also go into the virtualstore so the app works 'correctly', with one sidenote: You are not changing the file or regkey you think you are changing.
Reply With Quote
Reply

Tags
windows7 registry vb.net


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads
Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads
Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads
Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads
Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads
Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads
Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads
Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads
 
Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads
Can't Read/Write to registry - works in VB6 not VB.Net - Err 5 writing, no data reads
 
-->