Here's the code I use to define a Virtual Folder (Sorry if poorly formatted)

***************************************************************

[DllImport("kernel32.dll")]
   internal static extern bool DefineDosDevice(uint dwFlags, string 
lpDeviceName,
   string lpTargetPath);

[DllImport("Kernel32.dll")]
   internal static extern uint QueryDosDevice(string lpDeviceName,
   StringBuilder lpTargetPath, uint ucchMax);

internal const uint DDD_RAW_TARGET_PATH = 0x00000001;
        internal const uint DDD_REMOVE_DEFINITION = 0x00000002;
        internal const uint DDD_EXACT_MATCH_ON_REMOVE = 0x00000004;
        internal const uint DDD_NO_BROADCAST_SYSTEM = 0x00000008;

        const string MAPPED_FOLDER_INDICATOR = @"\??\";

*****************************************************
The Methods used are:
*****************************************************

internal static string MapFolderToDrive(string driveLetter, string folderName)
        {
            //Lets first check to see if we are already mapped
            StringBuilder Map_Drive = new StringBuilder(1024);
            QueryDosDevice(driveLetter, Map_Drive, (uint)1024);

            if (Map_Drive.ToString().StartsWith(MAPPED_FOLDER_INDICATOR) == 
true)
                UnmapFolderFromDrive(driveLetter, folderName);// already mapped;

            // Map the folder to the drive
            DefineDosDevice(0, driveLetter, folderName);

            // Display a status message to the user.
            string statusMessage = new 
Win32Exception(Marshal.GetLastWin32Error()).ToString();
            return statusMessage.Substring(statusMessage.IndexOf(":") + 1);
        }


internal static string UnmapFolderFromDrive(string driveLetter, string 
folderName)
        {
            DefineDosDevice(DDD_REMOVE_DEFINITION, driveLetter, folderName);

            string statusMessage = new 
Win32Exception(Marshal.GetLastWin32Error()).ToString();
            return statusMessage.Substring(statusMessage.IndexOf(":") + 1);
        }
*************************************************************************

Hope this helps.

Steve


>Would you be inclined to post (or send) the code for mimicking a virtual
>drive?

>Thanks,
>Mike



      
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to