[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System Environment.cs, 1.14,
From: |
Richard Baumann <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System Environment.cs, 1.14, 1.15 |
Date: |
Fri, 01 Aug 2003 13:53:10 -0400 |
Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System
In directory subversions:/tmp/cvs-serv19728/runtime/System
Modified Files:
Environment.cs
Log Message:
Apply reviewed savannah patches.
Index: Environment.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Environment.cs,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -r1.14 -r1.15
*** Environment.cs 21 Jun 2003 02:55:15 -0000 1.14
--- Environment.cs 1 Aug 2003 17:53:07 -0000 1.15
***************
*** 26,29 ****
--- 26,31 ----
using System.Diagnostics;
using System.IO;
+ using System.Runtime.CompilerServices;
+ using System.Runtime.InteropServices;
using System.Text;
using Platform;
***************
*** 304,307 ****
--- 306,310 ----
public enum SpecialFolder
{
+ Desktop = 0x00,
Programs = 0x02,
Personal = 0x05,
***************
*** 311,315 ****
--- 314,320 ----
SendTo = 0x09,
StartMenu = 0x0b,
+ MyMusic = 0x0d,
DesktopDirectory = 0x10,
+ MyComputer = 0x11,
Templates = 0x15,
ApplicationData = 0x1a,
***************
*** 321,324 ****
--- 326,330 ----
System = 0x25,
ProgramFiles = 0x26,
+ MyPictures = 0x27,
CommonProgramFiles = 0x2b
***************
*** 328,343 ****
public static String GetFolderPath(SpecialFolder folder)
{
! String path =
InfoMethods.GetSpecialFolder(folder);
! if(path != null)
{
! return path;
! }
! else if(folder == SpecialFolder.System)
! {
! return DirMethods.GetSystemDirectory();
}
else
{
! return null;
}
}
--- 334,378 ----
public static String GetFolderPath(SpecialFolder folder)
{
! if (Environment.OSVersion.Platform !=
(PlatformID)128/*PlatformID.Unix*/)
{
! // TODO: when auto-selection of
ANSI/Unicode version of DLL functions
! // will be implemented, do not
explicitely call the ANSI/Unicode
! // versions of SHGetFolderPath any more
! try
! {
! // TODO?: should the allocation
size be multiplied by 2 because of unicode chars ?
! IntPtr pathPtr=
Marshal.AllocHGlobal(260/*MAX_PATH*/ + 1);
! SHGetFolderPathW(IntPtr.Zero,
(Int32)folder, IntPtr.Zero, 0, pathPtr);
! String path=
Marshal.PtrToStringUni(pathPtr);
! Marshal.FreeHGlobal(pathPtr);
! return path;
! }
! catch (System.MissingMethodException e)
! {
! // SHGetFolderPathW could not
be found in the DLL
! try
! {
! IntPtr pathPtr=
Marshal.AllocHGlobal(260/*MAX_PATH*/ + 1);
!
SHGetFolderPathA(IntPtr.Zero, (Int32)folder, IntPtr.Zero, 0, pathPtr);
! String path=
Marshal.PtrToStringAnsi(pathPtr);
!
Marshal.FreeHGlobal(pathPtr);
! return path;
! }
! catch
(System.MissingMethodException e)
! {
! // SHGetFolderPathA
could not be found in the DLL
! return String.Empty;
! }
! }
! catch (System.DllNotFoundException e)
! {
! // shell32.dll could not be
found
! return String.Empty;
! }
}
else
{
! // TODO?: try to implement something
similar for non-Win32 platforms
! return String.Empty;
}
}
***************
*** 624,630 ****
}
}
-
};
}; // class Environment
--- 659,677 ----
}
}
};
+ // Import the Win32 SHGetFolderPathA function from "shell32.dll"
+ [DllImport("shell32.dll",CallingConvention=CallingConvention.Winapi)]
+ [MethodImpl(MethodImplOptions.PreserveSig)]
+ extern private static Int32 SHGetFolderPathA
+ (IntPtr hwndOwner, Int32 nFolder, IntPtr hToken,
+ UInt32 dwFlags, IntPtr path);
+
+ // Import the Win32 SHGetFolderPathW function from "shell32.dll"
+ [DllImport("shell32.dll",CallingConvention=CallingConvention.Winapi)]
+ [MethodImpl(MethodImplOptions.PreserveSig)]
+ extern private static Int32 SHGetFolderPathW
+ (IntPtr hwndOwner, Int32 nFolder, IntPtr hToken,
+ UInt32 dwFlags, IntPtr path);
}; // class Environment
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System Environment.cs, 1.14, 1.15,
Richard Baumann <address@hidden> <=