Solved

GetShortPathName and regedit

Posted on 2006-10-30
1
326 Views
Last Modified: 2008-03-10
Here is an article http://geekswithblogs.net/mnf/archive/2005/09/30/55580.aspx    that uses regedit to export a registry key....  The exporting is done in the following funtion

public static void ExportKey(RegistryKey rKey, string sfile)
{

            RegistryHelper.ExportKey(rKey.Name, sfile);

}

Now if you follow this function you will see that it calls a function

public static string GetShortFileName(string path)

            {

                  StringBuilder builder1 = new StringBuilder(0x400);

                  int num1 = GetShortPathName(ref path, builder1, builder1.Capacity);

                  return builder1.ToString(0, num1);

            }
I do not see why a call to get the shortpatname, 8.3 is required or why the builder1.ToString(0,num1) is required? Why can't we just pass in the regular path.  When do we have to worry about shortpath names?
0
Comment
Question by:dotnet22
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 total points
ID: 17840364
This function is used to pass .reg file name to Regedit. .reg file name can contain spaces, for example "C:\Program Files\MyDir\file1.reg". Passing parameter with spaces to regedit.exe program causes "File not found" error. There are two ways to solve this: short path which never contains spaces, or using "" for parameters. Code author decided to use short path name.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MailAddress in vb 4 36
Open a link in vb.net 2 26
Groupbox Control ? 2 27
What is newest platform to convert a massive Windows Forms program to? 7 52
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question