|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Troubles with User PermissionI am working with VB6 and XP Home Edition. I experience trouble when trying to access the windows registry and my app databases when the user has limited permission (i.e., has not system administrator permission). The databases, which are common for all users, are not accessible because they are locked in read-only mode (so I can't write on them), and the windows registry will not let me write on the HKEY_LOCAL_MACHINE key (where I need to write user-independent information for my app). Can anybody help and give some guidance on working with user permission from within VB6 code? Thanks in advance Carlos PS: I hope my explanation is clear... I'm sorry if it's not... I'm a newbie!!
Show quote
Hide quote
"CharlyE" <Char***@discussions.microsoft.com> wrote in message Well, not sure about the database being read-only. That may or may not have news:745C11B2-89AE-45B2-B8AA-2D11992E214C@microsoft.com... > Hi! > > I am working with VB6 and XP Home Edition. > > I experience trouble when trying to access the windows registry and my app > databases when the user has limited permission (i.e., has not system > administrator permission). > The databases, which are common for all users, are not accessible because > they are locked in read-only mode (so I can't write on them), and the > windows > registry will not let me write on the HKEY_LOCAL_MACHINE key (where I need > to > write user-independent information for my app). > > Can anybody help and give some guidance on working with user permission > from > within VB6 code? > anything to do with permissions or user privileges. You'd need to provide more information about this. For example, what is the database? Is it your own file format (i.e. you're using VB's file I/O statements and functions to read/write it). Is it an Access database? Some other RDMS? Where are the database files located? Regular users do not have permissions for many folders. For example, they may not have write permissions even to the application folder (the folder where your app is installed). This is why each user account has an Application Data (and other) folders under Documents and Settings. You might want to save your database files there. Since they are common for all users, you'd want them saved to "\Documents and Settings\All Users\Application Data" or perhaps "\Documents and Settings\All Users\Documents" (or a subfolder under either of these). Do NOT hard-code either of these paths in your app. Use the SHGetSpecialFolderPath Win32API function (and either CSIDL_COMMON_APPDATA or CSIDL_COMMON_DOCUMENTS) to get it. Search www.google.com if you need help or code examples for this function. If you need to support any Win9x systems, there will be alternate considerations. As far as the Registry, if these are "user-independent" settings, you're saving them to the wrong place. You need to save them to HKEY_CURRENT_USER. HKEY_LOCAL_MACHINE is for system-wide settings and only admins and power users have write permissions to anything under it (Power users aren't very common under WinXP because it's not an "available" user account type..a user must be specifically added to the Power Users group). Regular users can read from HKEY_LOCAL_MACHINE, but not write to it. Also, when opening Registry keys, never use KEY_ALL_ACCESS. This does not "grant" permissions that a user doesn't have. Use KEY_READ or KEY_WRITE as appropriate for the operation you need to perform. -- Mike Microsoft MVP Visual Basic Mike, thank you for your answer!
About the databases, they are Access databases located at the C:\Program files (don't know the exact english name for that folder... in spanish it's C:\Archivos de programa... i.e., the "default" installation folder). I'll try the "\Documents and Settings\All Users\Application Data" or "\Documents and Settings\All Users\Documents" approach. For the registry, I'll use the HKEY_CURRENT_USER. I thought that beeing "user-independent" settings, HKEY_LOCAL_MACHINE was the place... I was wrong! Thank you very much for your help! Carlos Show quoteHide quote "MikeD" wrote: > > "CharlyE" <Char***@discussions.microsoft.com> wrote in message > news:745C11B2-89AE-45B2-B8AA-2D11992E214C@microsoft.com... > > Hi! > > > > I am working with VB6 and XP Home Edition. > > > > I experience trouble when trying to access the windows registry and my app > > databases when the user has limited permission (i.e., has not system > > administrator permission). > > The databases, which are common for all users, are not accessible because > > they are locked in read-only mode (so I can't write on them), and the > > windows > > registry will not let me write on the HKEY_LOCAL_MACHINE key (where I need > > to > > write user-independent information for my app). > > > > Can anybody help and give some guidance on working with user permission > > from > > within VB6 code? > > > > > Well, not sure about the database being read-only. That may or may not have > anything to do with permissions or user privileges. You'd need to provide > more information about this. For example, what is the database? Is it your > own file format (i.e. you're using VB's file I/O statements and functions to > read/write it). Is it an Access database? Some other RDMS? Where are the > database files located? Regular users do not have permissions for many > folders. For example, they may not have write permissions even to the > application folder (the folder where your app is installed). This is why > each user account has an Application Data (and other) folders under > Documents and Settings. You might want to save your database files there. > Since they are common for all users, you'd want them saved to "\Documents > and Settings\All Users\Application Data" or perhaps "\Documents and > Settings\All Users\Documents" (or a subfolder under either of these). Do > NOT hard-code either of these paths in your app. Use the > SHGetSpecialFolderPath Win32API function (and either CSIDL_COMMON_APPDATA or > CSIDL_COMMON_DOCUMENTS) to get it. Search www.google.com if you need help > or code examples for this function. If you need to support any Win9x > systems, there will be alternate considerations. > > As far as the Registry, if these are "user-independent" settings, you're > saving them to the wrong place. You need to save them to HKEY_CURRENT_USER. > HKEY_LOCAL_MACHINE is for system-wide settings and only admins and power > users have write permissions to anything under it (Power users aren't very > common under WinXP because it's not an "available" user account type..a user > must be specifically added to the Power Users group). Regular users can > read from HKEY_LOCAL_MACHINE, but not write to it. Also, when opening > Registry keys, never use KEY_ALL_ACCESS. This does not "grant" permissions > that a user doesn't have. Use KEY_READ or KEY_WRITE as appropriate for the > operation you need to perform. > > -- > Mike > Microsoft MVP Visual Basic > > "CharlyE" <Char***@discussions.microsoft.com> wrote in message No, you were correct, but non-admins can't generally write to HKLM and thosenews:330CB91C-3D46-4C0E-8CD1-5072E51C149D@microsoft.com > For the registry, I'll use the HKEY_CURRENT_USER. I thought that > beeing "user-independent" settings, HKEY_LOCAL_MACHINE was the > place... I was wrong! users shouldn't be modifying system-wide settings. IMO the registry is the wrong place for application settings anyway. It makes much more sense to store them in your database (since you have that available anyway) or in an INI, XML or other file format of your choosing and put that file in the same place you put the database. -- Reply to the group so all can participate VB.Net: "Fool me once..." Bob, thanks for your contribution!
I thought about using the registry because I want some data to be "persistent", even in the case my app is unistalled... Considering this, in the case I used an INI file, where should I store it? Thanks Carlos Show quoteHide quote "Bob Butler" wrote: > "CharlyE" <Char***@discussions.microsoft.com> wrote in message > news:330CB91C-3D46-4C0E-8CD1-5072E51C149D@microsoft.com > > For the registry, I'll use the HKEY_CURRENT_USER. I thought that > > beeing "user-independent" settings, HKEY_LOCAL_MACHINE was the > > place... I was wrong! > > No, you were correct, but non-admins can't generally write to HKLM and those > users shouldn't be modifying system-wide settings. > > IMO the registry is the wrong place for application settings anyway. It > makes much more sense to store them in your database (since you have that > available anyway) or in an INI, XML or other file format of your choosing > and put that file in the same place you put the database. > > -- > Reply to the group so all can participate > VB.Net: "Fool me once..." > >
QB coder (in 4K!) struggles with vb concept (groan).
Microsoft Printer Compatibility Library 1.0 now available Why it does not convert ? Mouse events to moved picturebox Setting focus to the Form object required error Click Submit in Online Folder with Excel VB Send mail from VB6 dynamic array help advanced recordset sorting |
|||||||||||||||||||||||