RegistryItem with trailing backslashes

I’m finding some weird behavior with RegistryItems that were created using trailing backslashes:

Dim r As New RegistryItem("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MyApp\")  // note: trailing backslash
dim s as registryItem = r.parent
msgbox s.path
  // this shows 
  // HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MyApp
  // but i would expect 
  // HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\

It seems as if trailing backslashes don’t hurt when creating folders or setting values inside a folder, but that they do impact the use of .Parent()

I’m not sure if this is a bug, or my misunderstanding, or just perhaps a documentation error.

[quote=201008:@Michael Diehr]I’m finding some weird behavior with RegistryItems that were created using trailing backslashes:

Dim r As New RegistryItem("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MyApp\")  // note: trailing backslash
dim s as registryItem = r.parent
msgbox s.path
  // this shows 
  // HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MyApp
  // but i would expect 
  // HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\

It seems as if trailing backslashes don’t hurt when creating folders or setting values inside a folder, but that they do impact the use of .Parent()

I’m not sure if this is a bug, or my misunderstanding, or just perhaps a documentation error.[/quote]

Could be an issue with parsing. It is also possible the backslash represents a child of MyApp, with name “”. On the Internet, for instance, fontmenu.com/index.html is not the same as fontmenu.com/index.html/ where the trailing slash in the second will make index.html a folder.

In my specific case, I was testing code written for RealBasic 2010 which (I believe) didn’t have the .AddFolder method at all. It wasn’t working in RB2014r2.1 and the issue was with the backslash. I’m mostly writing this as a warning in case others have the same issue.

You are right. It could be an issue. I have found out on the Flexera Software (InstallShield) forums that apparently, Windows Installer automatically appends backslashes. https://community.flexerasoftware.com/showthread.php?19742-Backslash-on-Directory-Entries
which makes me suspect a large majority of installers based on MS recommendations do that.

I submitted this as <https://xojo.com/issue/40152>

The fact that RegistryItem.Value() and RegistryItem.Parent() behave differently when there is a trailing backslash seems like a possible bug to me. At the very least, the documentation should mention this if it’s not a bug.