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

Contents of /trunk/TSAdminTool/ShareUtil.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4 - (show annotations) (download)
Wed Jul 11 14:19:13 2012 UTC (7 years, 10 months ago) by william
File size: 1971 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
2 using System;
3 using System.Collections.Generic;
4 using System.Text;
5 using System.Diagnostics;
6 using System.Collections;
7 using System.Runtime.InteropServices;
8 using System.Management;
9 using System.Windows.Forms;
10
11 namespace AnywhereTS
12 {
13 // Provides services for creating, and deleting file shares. Also check if paths are local.
14 class ShareUtil
15 {
16 [DllImport("shlwapi.dll")]
17 private static extern bool PathIsNetworkPath(string
18 Path);
19
20 // Check if a path is a network path
21 // True = path is a network path.
22 public bool IsNetworkPath(string path)
23 {
24 return PathIsNetworkPath(path);
25 }
26
27 // Create a file share
28 public uint CreateShare(string Description, string Name, string Path)
29 {
30 ManagementClass classObj = new ManagementClass(null, "Win32_Share", null);
31 ManagementBaseObject mbo = null;
32 mbo = classObj.GetMethodParameters("Create"); // Call native method on Win32_Share class
33 mbo["Access"] = null; // default access permissions
34 mbo["Description"] = Description;
35 mbo["Name"] = Name;
36 mbo["Path"] = Path;
37 mbo["Type"] = 0; // Disk drive 0, print queue 1
38 ManagementBaseObject outParams = classObj.InvokeMethod("Create", mbo, null);
39 return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
40 }
41
42
43 // Delete the share with the name in string on this computer, if it exists
44 public void DeleteShare(string share)
45 {
46 ManagementObjectSearcher searcher = new
47 ManagementObjectSearcher("select * from win32_share where name = '" + share + "'");
48 foreach (ManagementObject moShare in searcher.Get())
49 {
50 moShare.Delete(); // Remove the share
51 }
52 }
53 }
54 }

  ViewVC Help
Powered by ViewVC 1.1.22