Solved

GetShortPathName and regedit

Posted on 2006-10-30
1
321 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 500 total points
Comment Utility
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 Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now