?
Solved

GetShortPathName and regedit

Posted on 2006-10-30
1
Medium Priority
?
333 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
1 Comment
 
LVL 48

Accepted Solution

by:
AlexFM earned 2000 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

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…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

840 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