/[AnywhereTS-MSSQL]/trunk/TSAdminTool/UNCconverter.cs
ViewVC logotype

Annotation of /trunk/TSAdminTool/UNCconverter.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4 - (hide annotations) (download)
Wed Jul 11 14:19:13 2012 UTC (8 years, 11 months ago) by william
File size: 1702 byte(s)
imported from https://anywherets.svn.sourceforge.net/svnroot/anywherets/trunk/
Revision: 1
Author: beartown
Date: 3:10:40 AM, Monday, June 21, 2010
Message:
First upload. Still todo in order to get a fully working product: Replace Thinstation images with vanilla Thinstation, modify ImageDesigntimeConfig.cs, ImageRuntimeConfig.cs in order to support the Thinstation image
1 william 4 using System;
2     using System.Collections.Generic;
3     using System.Text;
4     using System.Runtime.InteropServices;
5     using System.ComponentModel;
6    
7    
8     namespace AnywhereTS
9     {
10     static class UNCconverter
11     {
12     [DllImport("mpr.dll")]
13     public static extern int WNetGetUniversalName(
14     string lpLocalPath,
15     int dwInfoLevel,
16     ref StringBuilder lpBuffer,
17     ref int lpBufferSize);
18    
19    
20     const int UNIVERSAL_NAME_INFO_LEVEL = 1;
21     const int ERROR_MORE_DATA = 234;
22     // optional:
23     const int ERROR_NOT_CONNECTED = 2250;
24     const int MAX_PATH = 260;
25    
26    
27     public static string ConvertLocalPathToUnc(
28     string localPath)
29     {
30     StringBuilder buffer = new StringBuilder();
31     int size = 0;
32     // First call WNetGetUniversalName with an
33     // empty buffer to get size of buffer needed.
34     int retVal = WNetGetUniversalName(
35     localPath, UNIVERSAL_NAME_INFO_LEVEL,
36     ref buffer, ref size);
37     if (retVal == ERROR_MORE_DATA)
38     {
39     // WNetGetUniversalName returns the space
40     // needed in size, now allocate space for a
41     // buffer of this size.
42     buffer = new StringBuilder(size);
43     retVal = WNetGetUniversalName(
44     localPath, UNIVERSAL_NAME_INFO_LEVEL,
45     ref buffer, ref size);
46     if (retVal != 0)
47     {
48     throw new Win32Exception(retVal);
49     }
50     }
51     else
52     {
53     throw new Win32Exception(retVal);
54     }
55     return buffer.ToString();
56     }
57     }
58     }

  ViewVC Help
Powered by ViewVC 1.1.22