[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

GetShortPathName and regedit

Posted on 2006-10-30
1
Medium Priority
?
331 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 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

650 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