Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Win API: RegSaveKey / GetShortPathName

Win API: RegSaveKey / GetShortPathName

Scheduled Pinned Locked Moved C / C++ / MFC
helpwindows-adminjsonquestion
2 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Paul Riley
    wrote on last edited by
    #1

    Okay, I give up. Can anyone here help me with this: According to the MSDN docs for RegSaveKey: "Windows 95/98/Me: RegSaveKey does not support long file names. To save a registry hive to a file with a long file name, first save the hive to a short file name, then rename the resulting file to its long file name." And sure enough this seems to be the case, so I need to convert the filename to a short path. But when I call GetShortPathName, I get the error: The system cannot find the file specified. Well, obviously it can't find it, I'm about to create it. If I create the file to get the short path name then I need to remove it again before calling RegSaveKey, which doesn't seem to support overwriting existing files. So as far as I can gather, the only solution is to create a file, get it's short path name, delete the file and then call RegSaveKey. This seems very convoluted; does anyone have a better way that works? OR... have I completely missed the point here? I do notice that the long path name I'm trying to shorten has a double-backslash in it. C:\WINDOWS\TEMP\\{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA}\MyFolder\MyExtract.reg I didn't put it there, it's a Windows Installer API problem. It creates a support folder for installations ("[TEMPFOLDER]\[Product Code GUID]") and when you ask it for the path, you get it with the double-backslash. It hasn't caused me any issues up until this point, but I suppose it could cause the error from GetShortPathName. I don't know. Anybody? Paul

    P 1 Reply Last reply
    0
    • P Paul Riley

      Okay, I give up. Can anyone here help me with this: According to the MSDN docs for RegSaveKey: "Windows 95/98/Me: RegSaveKey does not support long file names. To save a registry hive to a file with a long file name, first save the hive to a short file name, then rename the resulting file to its long file name." And sure enough this seems to be the case, so I need to convert the filename to a short path. But when I call GetShortPathName, I get the error: The system cannot find the file specified. Well, obviously it can't find it, I'm about to create it. If I create the file to get the short path name then I need to remove it again before calling RegSaveKey, which doesn't seem to support overwriting existing files. So as far as I can gather, the only solution is to create a file, get it's short path name, delete the file and then call RegSaveKey. This seems very convoluted; does anyone have a better way that works? OR... have I completely missed the point here? I do notice that the long path name I'm trying to shorten has a double-backslash in it. C:\WINDOWS\TEMP\\{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA}\MyFolder\MyExtract.reg I didn't put it there, it's a Windows Installer API problem. It creates a support folder for installations ("[TEMPFOLDER]\[Product Code GUID]") and when you ask it for the path, you get it with the double-backslash. It hasn't caused me any issues up until this point, but I suppose it could cause the error from GetShortPathName. I don't know. Anybody? Paul

      P Offline
      P Offline
      Paul Riley
      wrote on last edited by
      #2

      Okay. I discounted the idea that the double-backslash was the problem by using a different folder. Then I realised that I could use GetShortPathName to get the name of the container folder and make sure the file names were 8.3 format when I added them. Problem soved. Doh! Paul

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups