2
Copyright (C) 2007, 2008, 2010 Jeroen Frijters
3
Copyright (C) 2009 - 2012 Volker Berlin (i-net software)
4
Copyright (C) 2010 Karsten Heinrich (i-net software)
6
This software is provided 'as-is', without any express or implied
7
warranty. In no event will the authors be held liable for any damages
8
arising from the use of this software.
10
Permission is granted to anyone to use this software for any purpose,
11
including commercial applications, and to alter it and redistribute it
12
freely, subject to the following restrictions:
14
1. The origin of this software must not be misrepresented; you must not
15
claim that you wrote the original software. If you use this software
16
in a product, an acknowledgment in the product documentation would be
17
appreciated but is not required.
18
2. Altered source versions must be plainly marked as such, and must not be
19
misrepresented as being the original software.
20
3. This notice may not be removed or altered from any source distribution.
27
using System.Runtime.InteropServices;
30
using System.Drawing.Imaging;
33
namespace IKVM.NativeCode.sun.awt
35
static class KeyboardFocusManagerPeerImpl
37
public static object getNativeFocusedWindow() { return null; }
38
public static object getNativeFocusOwner() { return null; }
39
public static void clearNativeGlobalFocusOwner(object activeWindow) { }
42
static class SunToolkit
44
public static void closeSplashScreen() { }
48
namespace IKVM.NativeCode.sun.awt.shell
51
/// This class should use only on Windows that we can access shell32.dll
53
public static class Win32ShellFolder2
55
private const uint IMAGE_BITMAP = 0;
56
private const uint IMAGE_ICON = 1;
58
private const int HINST_COMMCTRL = -1;
59
private const int IDB_VIEW_SMALL_COLOR = 4;
61
private const uint WM_USER = 0x0400;
62
private const uint TB_GETIMAGELIST = WM_USER + 49;
63
private const uint TB_LOADIMAGES = WM_USER + 50;
65
private const uint ILD_TRANSPARENT = 0x00000001;
67
private static readonly IntPtr hmodShell32;
68
private static readonly bool isXP;
70
[System.Security.SecuritySafeCritical]
71
static Win32ShellFolder2()
73
hmodShell32 = LoadLibrary("shell32.dll");
74
isXP = Environment.OSVersion.Version >= new Version(5, 1);
77
[System.Security.SecurityCritical]
78
private sealed class SafeGdiObjectHandle : Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid
80
private SafeGdiObjectHandle()
85
[System.Security.SecurityCritical]
86
protected override bool ReleaseHandle()
88
return DeleteObject(handle);
92
[System.Security.SecurityCritical]
93
private sealed class SafeDeviceContextHandle : Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid
95
[DllImport("user32.dll")]
96
private static extern int ReleaseDC(IntPtr hwnd, IntPtr hdc);
98
[DllImport("user32.dll")]
99
private static extern SafeDeviceContextHandle GetDC(IntPtr hwnd);
101
internal static SafeDeviceContextHandle Get()
103
return GetDC(IntPtr.Zero);
106
private SafeDeviceContextHandle()
111
[System.Security.SecurityCritical]
112
protected override bool ReleaseHandle()
114
return ReleaseDC(IntPtr.Zero, handle) == 1;
118
[DllImport("gdi32.dll")]
119
private static extern int GetDIBits(SafeDeviceContextHandle hdc, IntPtr hbmp, uint uStartScan, uint cScanLines, int[] lpvBits, ref BITMAPINFO lpbmi, uint uUsage);
121
[DllImport("gdi32.dll")]
122
private static extern int GetDIBits(SafeDeviceContextHandle hdc, SafeGdiObjectHandle hbmp, uint uStartScan, uint cScanLines, int[] lpvBits, ref BITMAPINFO lpbmi, uint uUsage);
124
[DllImport("gdi32.dll")]
125
private static extern int GetObject(SafeGdiObjectHandle hgdiobj, int cbBuffer, ref BITMAPINFO lpvObject);
127
[DllImport("shlwapi.dll")]
128
private static extern int StrRetToBuf(ref ShellApi.STRRET pstr, IntPtr pIDL, StringBuilder pszBuf, uint cchBuf);
130
[StructLayout(LayoutKind.Sequential)]
131
private struct ICONINFO
134
internal int xHotspot;
135
internal int yHotspot;
136
internal IntPtr hbmMask;
137
internal IntPtr hbmColor;
140
[DllImport("user32.dll")]
141
static extern bool GetIconInfo(IntPtr hIcon, out ICONINFO piconinfo);
143
[DllImport("user32.dll", SetLastError = true)]
144
static extern IntPtr CreateWindowEx(
158
[DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
159
[return: MarshalAs(UnmanagedType.Bool)]
160
static extern bool DestroyWindow(IntPtr hwnd);
162
[DllImport("user32.dll")]
163
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, Int32 wParam, Int32 lParam);
165
[DllImport("comctl32.dll", SetLastError = true)]
166
public static extern IntPtr ImageList_GetIcon(IntPtr himl, int i, uint flags);
168
[DllImport("comctl32")]
169
[return: MarshalAs(UnmanagedType.Bool)]
170
static extern bool ImageList_Destroy(IntPtr himl);
172
[DllImport("user32")]
173
public static extern int DestroyIcon(IntPtr hIcon);
175
[StructLayout(LayoutKind.Sequential)]
176
private struct BITMAPINFO
178
internal uint biSize;
179
internal int biWidth;
180
internal int biHeight;
181
internal ushort biPlanes;
182
internal ushort biBitCount;
183
internal uint biCompression;
184
internal uint biSizeImage;
185
internal int biXPelsPerMeter;
186
internal int biYPelsPerMeter;
187
internal uint biClrUsed;
188
internal uint biClrImportant;
189
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
190
internal uint[] cols;
193
[DllImport("user32.dll")]
194
private static extern SafeGdiObjectHandle LoadImage(IntPtr hInstance, IntPtr uID, uint type, int width, int height, int load);
196
[DllImport("user32.dll")]
197
private static extern SafeGdiObjectHandle LoadImage(IntPtr hInstance, string lpszName, uint type, int width, int height, int load);
199
[DllImport("kernel32.dll")]
200
private static extern IntPtr LoadLibrary(string Library);
202
[DllImport("gdi32.dll")]
203
private static extern bool DeleteObject(IntPtr hDc);
206
/// Get the program to execute or open the file. If it is a exe then it is self
208
/// <param name="path">path to the file</param>
209
/// <returns></returns>
210
[System.Security.SecuritySafeCritical]
211
public static string getExecutableType(string path)
213
StringBuilder objResultBuffer = new StringBuilder(1024);
214
int result = ShellApi.FindExecutable(path, path, objResultBuffer);
217
return objResultBuffer.ToString();
223
/// Get the type of a file or folder. On a file it depends on its extension.
225
/// <param name="path">the path of the file or folder</param>
226
/// <returns>The type in readable form or null, if the path cannot be resolved</returns>
227
[System.Security.SecuritySafeCritical]
228
public static string getFolderType(string path)
230
ShellApi.SHFILEINFO shinfo = new ShellApi.SHFILEINFO();
231
if (ShellApi.SHGetFileInfo(path, 0, out shinfo, (uint)Marshal.SizeOf(shinfo), ShellApi.SHGFI.SHGFI_TYPENAME) == IntPtr.Zero)
235
return shinfo.szTypeName;
238
[System.Security.SecurityCritical]
239
public static Bitmap getIconBits(IntPtr hIcon, int iconSize)
242
if (GetIconInfo(hIcon, out iconInfo))
244
using (SafeDeviceContextHandle dc = SafeDeviceContextHandle.Get())
246
BITMAPINFO bmi = new BITMAPINFO();
248
bmi.biWidth = iconSize;
249
bmi.biHeight = -iconSize;
252
bmi.biCompression = 0;
253
int intArrSize = iconSize * iconSize;
254
int[] iconBits = new int[intArrSize];
255
GetDIBits(dc, iconInfo.hbmColor, 0, (uint)iconSize, iconBits, ref bmi, 0);
256
bool hasAlpha = false;
259
for (int i = 0; i < iconBits.Length; i++)
261
if ((iconBits[i] & 0xFF000000) != 0)
270
int[] maskBits = new int[intArrSize];
271
GetDIBits(dc, iconInfo.hbmMask, 0, (uint)iconSize, maskBits, ref bmi, 0);
272
for (int i = 0; i < iconBits.Length; i++)
274
if (maskBits[i] == 0)
276
iconBits[i] = (int)((uint)iconBits[i] | 0xFF000000);
280
DeleteObject(iconInfo.hbmColor);
281
DeleteObject(iconInfo.hbmMask);
284
Bitmap bitmap = new Bitmap(iconSize, iconSize, PixelFormat.Format32bppArgb);
285
BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, iconSize, iconSize), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
286
Marshal.Copy(iconBits, 0, bitmapData.Scan0, iconBits.Length);
287
bitmap.UnlockBits(bitmapData);
295
/// Retrieves information about an object in the file system, such as a file, folder, directory, or drive root.
297
/// <param name="path">The path of the file system object</param>
298
/// <returns>The SHGFI flags with the attributes</returns>
299
[System.Security.SecuritySafeCritical]
300
public static int getAttribute(string path)
302
ShellApi.SHFILEINFO shinfo = new ShellApi.SHFILEINFO();
303
if (ShellApi.SHGetFileInfo(path, 0, out shinfo, (uint)Marshal.SizeOf(shinfo), ShellApi.SHGFI.SHGFI_ATTRIBUTES) == IntPtr.Zero)
307
return (int)shinfo.dwAttributes;
310
/// <summary>Returns the link target as a pIDL relative to the desktop without resolving the link</summary>
311
/// <param name="path">The path of the .lnk file</param>
312
/// <returns>the link target as a pIDL relative to the desktop</returns>
313
[System.Security.SecuritySafeCritical]
314
public static string getLinkLocation(string path )
316
using (ShellLink link = new ShellLink())
319
return link.GetPath();
322
/// <summary>Returns the link target as a pIDL relative to the desktop</summary>
323
/// <param name="path">The path of the .lnk file</param>
324
/// <param name="resolve">If true, attempts to find the target of a Shell link,
325
/// even if it has been moved or renamed. This may open a file chooser</param>
326
/// <returns>the link target as a pIDL relative to the desktop</returns>
327
[System.Security.SecuritySafeCritical]
328
public static IntPtr getLinkLocation(string path, Boolean resolve)
330
using (ShellLink link = new ShellLink())
337
return link.GetIDList();
341
// Code copied from Java_sun_awt_shell_Win32ShellFolder2_getStandardViewButton0
342
[System.Security.SecuritySafeCritical]
343
public static Bitmap getStandardViewButton0(int iconIndex)
345
Bitmap result = null;
346
using (new ThemingActivationContext())
349
IntPtr hWndToolbar = CreateWindowEx(0, "ToolbarWindow32", null, 0, 0, 0, 0, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
350
if (hWndToolbar != IntPtr.Zero)
352
SendMessage(hWndToolbar, TB_LOADIMAGES, IDB_VIEW_SMALL_COLOR, HINST_COMMCTRL);
354
IntPtr hImageList = SendMessage(hWndToolbar, TB_GETIMAGELIST, 0, 0);
355
if (hImageList != IntPtr.Zero)
357
IntPtr hIcon = ImageList_GetIcon(hImageList, iconIndex, ILD_TRANSPARENT);
358
if (hIcon != IntPtr.Zero)
360
Icon icon = Icon.FromHandle(hIcon);
361
result = icon.ToBitmap();
365
ImageList_Destroy(hImageList);
367
DestroyWindow(hWndToolbar);
374
/// Retrieves an icon from the shell32.dell
376
/// <param name="iconID">the index of the icon</param>
377
/// <returns>The icon or null, if there is no icon at the given index</returns>
378
[System.Security.SecuritySafeCritical]
379
public static Bitmap getShell32IconResourceAsBitmap(int iconID, bool getLargeIcon)
381
if (hmodShell32 == IntPtr.Zero)
385
int size = getLargeIcon ? 32 : 16;
386
using (SafeGdiObjectHandle hicon = LoadImage(hmodShell32, (IntPtr)iconID, IMAGE_ICON, size, size, 0))
390
return getIconBits(hicon.DangerousGetHandle(), 16);
397
/// Returns the pIDL of the desktop itself
399
[System.Security.SecurityCritical]
400
public static IntPtr initDesktopPIDL()
402
IntPtr pidl = new IntPtr();
404
// get the root shell folder
405
ShellApi.SHGetSpecialFolderLocation(IntPtr.Zero, ShellApi.CSIDL.CSIDL_DESKTOP, ref pidl);
411
/// Returns an IShellFolder for the desktop
413
[System.Security.SecurityCritical]
414
public static Object initDesktopFolder()
416
ShellApi.IShellFolder rootShell = null;
418
// get the root shell folder
419
ShellApi.SHGetDesktopFolder(ref rootShell);
425
/// Returns the desktop relative pIDL of a special folder
427
/// <param name="desktopIShellFolder">The IShellFolder instance of the Desktop</param>
428
/// <param name="csidl">The CSIDL of the special folder</param>
429
/// <returns>the desktop relative pIDL of a special folder</returns>
430
[System.Security.SecurityCritical]
431
public static IntPtr initSpecialPIDL(Object desktopIShellFolder, int csidl)
433
IntPtr result = new IntPtr();
434
ShellApi.SHGetSpecialFolderLocation(IntPtr.Zero, (ShellApi.CSIDL)csidl, ref result);
439
/// Creates an IShellFolder for a special folder
441
/// <param name="desktopIShellFolder">The IShellFolder instance of the Desktop</param>
442
/// <param name="pidl">The desktop relative pIDL of the special folder</param>
443
/// <returns>The IShellFolder for a special folder</returns>
444
[System.Security.SecurityCritical]
445
public static Object initSpecialFolder(Object desktopIShellFolder, IntPtr pidl)
449
// get desktop instance
450
ShellApi.IShellFolder desktop = (ShellApi.IShellFolder)desktopIShellFolder;
451
// call BindToObject of the desktop
452
ShellApi.IShellFolder specialFolder = null;
453
desktop.BindToObject(pidl, IntPtr.Zero, ref ShellApi.GUID_ISHELLFOLDER, out specialFolder);
454
return specialFolder;
456
catch (System.ArgumentException )
463
/// Goes down one entry in the given pIDL
465
/// <param name="pIDL">the pIDL to operate on</param>
466
/// <returns>the next entry in the pIDL</returns>
467
[System.Security.SecurityCritical]
468
public static IntPtr getNextPIDLEntry(IntPtr pIDL)
470
if (pIDL == IntPtr.Zero)
475
int length = Marshal.ReadInt16(pIDL);
476
if (length == 0) // defined as terminator of a ITEMIDLIST
480
IntPtr newpIDL = new IntPtr(pIDL.ToInt64() + length);
481
if (Marshal.ReadInt16(newpIDL) == 0)
491
/// Copies the first entry in the given pIDL into a new relative pIDL (with terminator)
493
/// <param name="pIDL">The pIDL to copy from</param>
494
/// <returns>the relative pIDL of the first entry</returns>
495
[System.Security.SecurityCritical]
496
public static IntPtr copyFirstPIDLEntry(IntPtr pIDL)
498
if (pIDL == IntPtr.Zero)
502
int length = Marshal.ReadInt16(pIDL) + 2; // +2 for the terminator
503
byte[] buffer = new byte[length];
504
IntPtr newpIDLptr = Marshal.AllocCoTaskMem(length); // create pointer to new pIDL
505
Marshal.Copy(pIDL, buffer, 0, length - 2); // copy content
506
Marshal.Copy(buffer, 0, newpIDLptr, length); // copy content
511
/// Concatinates two pIDLs
513
/// <param name="ppIDL">a pIDL, if IntPtr.Zero, IntPtr.Zero will be returned</param>
514
/// <param name="pIDL">a pIDL, if IntPtr.Zero, IntPtr.Zero will be returned</param>
515
/// <returns>the concatination of ppIDL and pIDL</returns>
516
[System.Security.SecurityCritical]
517
public static IntPtr combinePIDLs(IntPtr ppIDL, IntPtr pIDL)
519
if (ppIDL == IntPtr.Zero)
523
if (pIDL == IntPtr.Zero)
527
int lengthP = getPIDLlength(ppIDL);
528
int lengthR = getPIDLlength(pIDL);
529
byte[] newPIDL = new byte[lengthP + lengthR + 2];
530
Marshal.Copy(ppIDL, newPIDL, 0, lengthP);
531
Marshal.Copy(pIDL, newPIDL, lengthP, lengthR);
532
IntPtr newpIDLptr = Marshal.AllocCoTaskMem(lengthP + lengthR + 2); // create pointer to new pIDL
533
Marshal.Copy(newPIDL,0,newpIDLptr,newPIDL.Length); // set pointer to new pIDL and delete local structure
538
/// Calculates the size of a ITEMIDLIST without the two bytes of the terminator
540
/// <param name="pIDL">a pointer to the IDL to get the length of</param>
541
/// <returns>the length in bytes</returns>
542
[System.Security.SecurityCritical]
543
public static int getPIDLlength(IntPtr pIDL)
545
if( pIDL == IntPtr.Zero )
549
int length = Marshal.ReadInt16(pIDL);
553
length = Marshal.ReadInt16(new IntPtr( pIDL.ToInt64() + offset));
559
/// Releases the allocted memory of a pIDL
561
/// <param name="pIDL">The pIDL to be released</param>
562
[System.Security.SecurityCritical]
563
public static void releasePIDL(IntPtr pIDL)
565
if (pIDL == IntPtr.Zero)
569
Marshal.Release(pIDL);
573
/// Releases an IShellFolder COM object
575
/// <param name="pIShellFolder">The IShellFolder to be released, must not be null</param>
576
[System.Security.SecurityCritical]
577
public static void releaseIShellFolder(Object pIShellFolder)
579
if (pIShellFolder == null)
583
Marshal.ReleaseComObject(pIShellFolder);
586
[System.Security.SecurityCritical]
587
public static int compareIDs(Object pParentIShellFolder, IntPtr pidl1, IntPtr pidl2)
589
if (pParentIShellFolder == null)
593
ShellApi.IShellFolder folder = (ShellApi.IShellFolder)pParentIShellFolder;
594
return folder.CompareIDs(0, pidl1, pidl2);
597
[System.Security.SecurityCritical]
598
public static int getAttributes0(Object pParentIShellFolder, IntPtr pIDL, int attrsMask)
600
if (pParentIShellFolder == null || pIDL == IntPtr.Zero )
604
ShellApi.IShellFolder folder = (ShellApi.IShellFolder)pParentIShellFolder;
605
ShellApi.SFGAOF[] atts = new ShellApi.SFGAOF[]{ (ShellApi.SFGAOF)attrsMask };
606
IntPtr[] pIDLs = new IntPtr[] { pIDL };
607
folder.GetAttributesOf(1, pIDLs, atts);
611
[System.Security.SecurityCritical]
612
public static String getFileSystemPath(int csidl)
614
IntPtr pIDL = new IntPtr();
615
int hRes = ShellApi.SHGetSpecialFolderLocation(IntPtr.Zero, (ShellApi.CSIDL)csidl, ref pIDL);
618
//throw Marshal.ThrowExceptionForHR(hRes);
619
// TODO exception for hRes
622
StringBuilder builder = new StringBuilder( 1024 );
623
if (ShellApi.SHGetPathFromIDList(pIDL, builder))
625
return builder.ToString();
633
[System.Security.SecurityCritical]
634
public static Object getEnumObjects(Object pIShellFolder, Boolean isDesktop, Boolean includeHiddenFiles)
636
if (pIShellFolder == null)
640
ShellApi.IShellFolder folder = (ShellApi.IShellFolder)pIShellFolder;
641
ShellApi.SHCONTF flags = ShellApi.SHCONTF.SHCONTF_FOLDERS | ShellApi.SHCONTF.SHCONTF_NONFOLDERS;
642
if( includeHiddenFiles )
644
flags |= ShellApi.SHCONTF.SHCONTF_INCLUDEHIDDEN;
647
ShellApi.IEnumIDList list = null;
648
folder.EnumObjects(IntPtr.Zero, flags, out list);
653
/// Returns the next pIDL in an IEnumIDList
655
/// <param name="pEnumObjects">The IEnumIDList to get the next element of</param>
656
/// <returns>a pIDL or IntPtr.Zero in case the end of the enum is reached</returns>
657
[System.Security.SecurityCritical]
658
public static IntPtr getNextChild(Object pEnumObjects)
660
if (pEnumObjects == null)
664
ShellApi.IEnumIDList list = (ShellApi.IEnumIDList)pEnumObjects;
665
IntPtr pIDL = new IntPtr();
666
int pceltFetched; // can be ignored, if celt = 1
667
uint hRes = list.Next(1, out pIDL, out pceltFetched);
668
if ( hRes != 0 || pceltFetched == 0 )
679
/// Releases an IEnumIDList
681
/// <param name="pEnumObjects">The IEnumIDList to be released</param>
682
[System.Security.SecurityCritical]
683
public static void releaseEnumObjects(Object pEnumObjects)
685
if (pEnumObjects != null)
687
Marshal.ReleaseComObject(pEnumObjects);
692
/// Binds an IShellFolder to the child of a given shell folder
694
/// <param name="parentIShellFolder">the parent IShellFolder</param>
695
/// <param name="pIDL">the relative pIDL to the child</param>
696
/// <returns>The IShellFolder of the child or null, if there is no such child</returns>
697
[System.Security.SecurityCritical]
698
public static Object bindToObject(Object parentIShellFolder, IntPtr pIDL)
700
if (parentIShellFolder == null || pIDL == IntPtr.Zero )
704
ShellApi.IShellFolder folder = (ShellApi.IShellFolder)parentIShellFolder;
705
ShellApi.IShellFolder newFolder = null;
706
folder.BindToObject(pIDL, IntPtr.Zero, ref ShellApi.GUID_ISHELLFOLDER, out newFolder);
711
/// Parses the displayname of a child of a given folder
713
/// <param name="pIShellFolder">The IShellFolder to get the chilf of</param>
714
/// <param name="name">The display name of the child</param>
715
/// <returns>the relative pIDL of the child or IntPrt.Zero in case there is no such child</returns>
716
[System.Security.SecurityCritical]
717
public static IntPtr parseDisplayName0(Object pIShellFolder, String name)
719
if (pIShellFolder == null)
723
ShellApi.IShellFolder folder = (ShellApi.IShellFolder)pIShellFolder;
724
IntPtr pIDL = new IntPtr();
726
uint pdwAttribute = 0;
727
folder.ParseDisplayName(IntPtr.Zero, IntPtr.Zero, name, out pchEaten, out pIDL, ref pdwAttribute);
731
[System.Security.SecurityCritical]
732
public static String getDisplayNameOf(Object parentIShellFolder, IntPtr relativePIDL, int attrs)
734
if (parentIShellFolder == null || relativePIDL == IntPtr.Zero)
738
ShellApi.IShellFolder folder = (ShellApi.IShellFolder)parentIShellFolder;
739
ShellApi.STRRET result;
740
uint hRes = folder.GetDisplayNameOf(relativePIDL, (ShellApi.SHGDN)attrs, out result);
743
StringBuilder name = new StringBuilder( 1024 );
744
StrRetToBuf(ref result, relativePIDL, name, 1024);
745
string stringName = name.ToString();
751
[System.Security.SecurityCritical]
752
public static String getFolderType(IntPtr pIDL)
754
ShellApi.SHFILEINFO fileInfo = new ShellApi.SHFILEINFO();
755
ShellApi.SHGetFileInfo(pIDL, 0, out fileInfo, (uint)Marshal.SizeOf(fileInfo), ShellApi.SHGFI.SHGFI_PIDL | ShellApi.SHGFI.SHGFI_TYPENAME);
756
return fileInfo.szTypeName;
759
public static Object getIShellIcon(Object pIShellFolder)
761
if (pIShellFolder is ShellApi.IShellIcon)
763
return pIShellFolder;
768
[System.Security.SecurityCritical]
769
public static int getIconIndex(Object parentIShellFolder, IntPtr relativePIDL)
771
if (parentIShellFolder is ShellApi.IShellIcon)
773
ShellApi.IShellIcon shellIcon = (ShellApi.IShellIcon)parentIShellFolder;
775
if( shellIcon.GetIconOf(relativePIDL, (uint)ShellApi.GIL.GIL_FORSHELL, out index) == 0 )
783
[System.Security.SecurityCritical]
784
public static IntPtr getIcon(String absolutePath, Boolean getLargeIcon)
786
ShellApi.SHFILEINFO shinfo = new ShellApi.SHFILEINFO();
787
if (ShellApi.SHGetFileInfo(absolutePath, 0, out shinfo, (uint)Marshal.SizeOf(shinfo), ShellApi.SHGFI.SHGFI_ICON | (getLargeIcon ? ShellApi.SHGFI.SHGFI_LARGEICON : ShellApi.SHGFI.SHGFI_SMALLICON)) == IntPtr.Zero)
794
[System.Security.SecurityCritical]
795
public static IntPtr extractIcon(Object parentIShellFolder, IntPtr relativePIDL, Boolean getLargeIcon)
797
if (parentIShellFolder == null || relativePIDL == IntPtr.Zero)
801
ShellApi.IShellFolder folder = (ShellApi.IShellFolder)parentIShellFolder;
802
Guid guid = new Guid("000214fa-0000-0000-c000-000000000046");
804
if (folder.GetUIObjectOf(IntPtr.Zero, 1, new IntPtr[] { relativePIDL }, ref guid, IntPtr.Zero, out ppv) == 0)
806
ShellApi.IExtractIcon extractor = (ShellApi.IExtractIcon)ppv;
808
StringBuilder path = new StringBuilder( size );
811
if (extractor.GetIconLocation((uint)ShellApi.GIL.GIL_FORSHELL, path, size, out piIndex, out pwFlags) == 0)
813
IntPtr hIconL = new IntPtr();
814
IntPtr hIconS = new IntPtr();
815
if (extractor.Extract(path.ToString(), (uint)piIndex, out hIconL, out hIconS, (16 << 16) + 32) == 0)
819
ShellApi.DestroyIcon(hIconS);
824
ShellApi.DestroyIcon(hIconL);
833
[System.Security.SecurityCritical]
834
public static void disposeIcon(IntPtr hIcon)
836
ShellApi.DestroyIcon(hIcon);
839
public static Object doGetColumnInfo(Object iShellFolder2)
845
public static Object doGetColumnValue(Object parentIShellFolder2, IntPtr childPIDL, int columnIdx)
851
public static int compareIDsByColumn(Object pParentIShellFolder, IntPtr pidl1, IntPtr pidl2, int columnIdx)
858
[System.Security.SecurityCritical]
859
class ShellLink : IDisposable
862
[Guid("0000010B-0000-0000-C000-000000000046")]
863
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
864
internal interface IPersistFile
867
void GetClassID(out Guid pClassID);
871
void Load([MarshalAs(UnmanagedType.LPWStr)] string pszFileName, uint dwMode);
873
void Save([MarshalAs(UnmanagedType.LPWStr)] string pszFileName, [MarshalAs(UnmanagedType.Bool)] bool fRemember);
875
void SaveCompleted([MarshalAs(UnmanagedType.LPWStr)] string pszFileName);
877
void GetCurFile([MarshalAs(UnmanagedType.LPWStr)] out string ppszFileName);
881
[Guid("000214F9-0000-0000-C000-000000000046")]
882
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
883
private interface IShellLinkW
885
void GetPath([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile, int cchMaxPath, IntPtr pfd, uint fFlags);
886
void GetIDList(out IntPtr ppidl);
887
void SetIDList(IntPtr pidl);
888
void GetDescription([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile, int cchMaxName);
889
void SetDescription([MarshalAs(UnmanagedType.LPWStr)] string pszName);
890
void GetWorkingDirectory([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszDir, int cchMaxPath);
891
void SetWorkingDirectory([MarshalAs(UnmanagedType.LPWStr)] string pszDir);
892
void GetArguments([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszArgs, int cchMaxPath);
893
void SetArguments([MarshalAs(UnmanagedType.LPWStr)] string pszArgs);
894
void GetHotkey(out short pwHotkey);
895
void SetHotkey(short pwHotkey);
896
void GetShowCmd(out uint piShowCmd);
897
void SetShowCmd(uint piShowCmd);
898
void GetIconLocation([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszIconPath, int cchIconPath, out int piIcon);
899
void SetIconLocation([MarshalAs(UnmanagedType.LPWStr)] string pszIconPath, int iIcon);
900
void SetRelativePath([MarshalAs(UnmanagedType.LPWStr)] string pszPathRel, uint dwReserved);
901
/// <summary>Attempts to find the target of a Shell link, even if it has been moved or renamed.</summary>
902
void Resolve(IntPtr hWnd, uint fFlags);
903
void SetPath([MarshalAs(UnmanagedType.LPWStr)] string pszFile);
906
[Guid("00021401-0000-0000-C000-000000000046")]
907
[ClassInterfaceAttribute(ClassInterfaceType.None)]
909
private class CShellLink { }
912
public enum EShowWindowFlags : uint
917
SW_SHOWMINIMIZED = 2,
918
SW_SHOWMAXIMIZED = 3,
920
SW_SHOWNOACTIVATE = 4,
923
SW_SHOWMINNOACTIVE = 7,
930
private IShellLinkW linkW = (IShellLinkW)new CShellLink();
932
[System.Security.SecuritySafeCritical]
933
public void Dispose()
937
Marshal.ReleaseComObject(linkW);
942
public void SetPath(string path)
947
public void SetDescription(string description)
949
linkW.SetDescription(description);
952
public void SetWorkingDirectory(string dir)
954
linkW.SetWorkingDirectory(dir);
957
public void SetArguments(string args)
959
linkW.SetArguments(args);
962
public void SetShowCmd(EShowWindowFlags cmd)
964
linkW.SetShowCmd((uint)cmd);
967
public void Save(string linkFile)
969
((IPersistFile)linkW).Save(linkFile, true);
972
public void Load(string linkFile)
974
((IPersistFile)linkW).Load(linkFile, 0);
977
public string GetArguments()
979
StringBuilder sb = new StringBuilder(512);
980
linkW.GetArguments(sb, sb.Capacity);
981
return sb.ToString();
984
public void Resolve()
986
linkW.Resolve(IntPtr.Zero, 0);
989
public IntPtr GetIDList(){
991
linkW.GetIDList( out ppidl );
995
public string GetPath()
997
StringBuilder sb = new StringBuilder(512);
998
linkW.GetPath(sb, sb.Capacity, IntPtr.Zero, 0);
999
return sb.ToString();
1006
namespace IKVM.NativeCode.sun.java2d
1008
static class DefaultDisposerRecord
1010
public static void invokeNativeDispose(long disposerMethodPointer, long dataPointer)
1012
throw new NotImplementedException();
1016
static class Disposer
1018
public static void initIDs()
1024
namespace IKVM.NativeCode.sun.java2d.pipe
1028
public static void initIDs() { }
1031
static class RenderBuffer
1033
public static void copyFromArray(object srcArray, long srcPos, long dstAddr, long length)
1035
throw new NotImplementedException();