public static Boolean DoAutoComplete(IntPtr hwndEdit, AutoCompleteFlags flags) { Int32 hRet; hRet = ShellApi.SHAutoComplete(hwndEdit, (UInt32)flags); return(hRet == 0); }
private Boolean AppbarNew() { if (CallbackMessageID == 0) { throw new Exception("CallbackMessageID is 0"); } if (IsAppbarMode) { return(true); } m_PrevSize = Size; m_PrevLocation = Location; // prepare data structure of message ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA(); msgData.cbSize = (UInt32)Marshal.SizeOf(msgData); msgData.hWnd = Handle; msgData.uCallbackMessage = CallbackMessageID; // install new appbar UInt32 retVal = ShellApi.SHAppBarMessage((UInt32)AppBarMessages.New, ref msgData); IsAppbarMode = (retVal != 0); SizeAppBar(); return(IsAppbarMode); }
private void AppbarWindowPosChanged() { // prepare data structure of message ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA(); msgData.cbSize = (UInt32)Marshal.SizeOf(msgData); msgData.hWnd = Handle; // send windowposchanged to the system ShellApi.SHAppBarMessage((UInt32)AppBarMessages.WindowPosChanged, ref msgData); }
private void AppbarActivate() { // prepare data structure of message ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA(); msgData.cbSize = (UInt32)Marshal.SizeOf(msgData); msgData.hWnd = Handle; // send activate to the system ShellApi.SHAppBarMessage((UInt32)AppBarMessages.Activate, ref msgData); }
private void AppbarSetTaskbarState(AppBarStates state) { // prepare data structure of message ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA(); msgData.cbSize = (UInt32)Marshal.SizeOf(msgData); msgData.lParam = (Int32)state; // set taskbar state ShellApi.SHAppBarMessage((UInt32)AppBarMessages.SetState, ref msgData); }
private void AppbarGetTaskbarPos(out ShellApi.RECT taskRect) { // prepare data structure of message ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA(); msgData.cbSize = (UInt32)Marshal.SizeOf(msgData); // get taskbar position ShellApi.SHAppBarMessage((UInt32)AppBarMessages.GetTaskBarPos, ref msgData); taskRect = msgData.rc; }
private AppBarStates AppbarGetTaskbarState() { // prepare data structure of message ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA(); msgData.cbSize = (UInt32)Marshal.SizeOf(msgData); // get taskbar state UInt32 retVal = ShellApi.SHAppBarMessage((UInt32)AppBarMessages.GetState, ref msgData); return((AppBarStates)retVal); }
public static IMalloc GetMalloc() { IntPtr ptrRet; ShellApi.SHGetMalloc(out ptrRet); Object obj = Marshal.GetTypedObjectForIUnknown(ptrRet, GetMallocType()); IMalloc imalloc = (IMalloc)obj; return(imalloc); }
public static IShellFolder GetDesktopFolder() { IntPtr ptrRet; ShellApi.SHGetDesktopFolder(out ptrRet); System.Type shellFolderType = System.Type.GetType("ShellLib.IShellFolder"); Object obj = Marshal.GetTypedObjectForIUnknown(ptrRet, shellFolderType); IShellFolder ishellFolder = (IShellFolder)obj; return(ishellFolder); }
private IntPtr AppbarGetAutoHideBar(AppBarEdges edge) { // prepare data structure of message ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA(); msgData.cbSize = (UInt32)Marshal.SizeOf(msgData); msgData.uEdge = (UInt32)edge; // get auto hide IntPtr retVal = (IntPtr)ShellApi.SHAppBarMessage((UInt32)AppBarMessages.GetAutoHideBar, ref msgData); return(retVal); }
public CopyFileResult DoOperation(ref String errorMessage) { errorMessage = ""; ShellApi.SHFILEOPSTRUCT FileOpStruct = new ShellApi.SHFILEOPSTRUCT(); FileOpStruct.hwnd = OwnerWindow; FileOpStruct.wFunc = (uint)Operation; String multiSource = StringArrayToMultiString(SourceFiles); String multiDest = StringArrayToMultiString(DestFiles); FileOpStruct.pFrom = Marshal.StringToHGlobalUni(multiSource); FileOpStruct.pTo = Marshal.StringToHGlobalUni(multiDest); FileOpStruct.fFlags = (ushort)OperationFlags; FileOpStruct.lpszProgressTitle = ProgressTitle; FileOpStruct.fAnyOperationsAborted = 0; FileOpStruct.hNameMappings = IntPtr.Zero; RetVal = ShellApi.SHFileOperation(ref FileOpStruct); ShellApi.SHChangeNotify( (uint)ShellChangeNotificationEvents.SHCNE_ALLEVENTS, (uint)ShellChangeNotificationFlags.SHCNF_DWORD, IntPtr.Zero, IntPtr.Zero); if (FileOpStruct.fAnyOperationsAborted != 0) { return(CopyFileResult.Aborted); } // If RetVal is 0, we are then sure that the operation succeeded. if (RetVal == 0) { return(CopyFileResult.Completed); } // In this case, the operation failed. We need to report why. // From http://msdn.microsoft.com/en-us/library/bb762164(VS.85).aspx, // we cannot map some of the return values of ShFileOperation() to Win32 error // strings, let's use a custom dictionnary to perform the appropriate mapping. if (ShFileOpErrorMap.ContainsKey(RetVal)) { errorMessage = ShFileOpErrorMap[RetVal]; } else { errorMessage = "Unknown error message: " + RetVal; } return(CopyFileResult.Failed); }
private void AppbarSetPos(ref ShellApi.RECT appRect) { // prepare data structure of message ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA(); msgData.cbSize = (UInt32)Marshal.SizeOf(msgData); msgData.hWnd = Handle; msgData.uEdge = (UInt32)m_Edge; msgData.rc = appRect; // set postion for the appbar ShellApi.SHAppBarMessage((UInt32)AppBarMessages.SetPos, ref msgData); appRect = msgData.rc; }
private Boolean AppbarSetAutoHideBar(Boolean hideValue) { // prepare data structure of message ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA(); msgData.cbSize = (UInt32)Marshal.SizeOf(msgData); msgData.hWnd = Handle; msgData.uEdge = (UInt32)m_Edge; msgData.lParam = (hideValue) ? 1 : 0; // set auto hide UInt32 retVal = ShellApi.SHAppBarMessage((UInt32)AppBarMessages.SetAutoHideBar, ref msgData); return((retVal != 0) ? true : false); }
public bool Execute() { int iRetVal; iRetVal = (int)ShellApi.ShellExecute( OwnerHandle, Verb, Path, Parameters, WorkingFolder, (int)ShowMode); return((iRetVal > 32) ? true : false); }
private Boolean AppbarRemove() { // prepare data structure of message ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA(); msgData.cbSize = (UInt32)Marshal.SizeOf(msgData); msgData.hWnd = Handle; // remove appbar UInt32 retVal = ShellApi.SHAppBarMessage((UInt32)AppBarMessages.Remove, ref msgData); IsAppbarMode = false; Size = m_PrevSize; Location = m_PrevLocation; return((retVal != 0) ? true : false); }
// Allows a client to specify which individual items should be enumerated. // Note: The host calls this method for each item in the folder. Return S_OK, to have the item enumerated. // Return S_FALSE to prevent the item from being enumerated. public Int32 ShouldShow( Object psf, // A pointer to the folder's IShellFolder interface. IntPtr pidlFolder, // The folder's PIDL. IntPtr pidlItem) // The item's PIDL. { // check extension, and if not ok return 1 (S_FALSE) // get display name of item IShellFolder isf = (IShellFolder)psf; ShellApi.STRRET ptrDisplayName; isf.GetDisplayNameOf(pidlItem, (uint)ShellApi.SHGNO.SHGDN_NORMAL | (uint)ShellApi.SHGNO.SHGDN_FORPARSING, out ptrDisplayName); String sDisplay; ShellApi.StrRetToBSTR(ref ptrDisplayName, (IntPtr)0, out sDisplay); // check if item is file or folder IntPtr[] aPidl = new IntPtr[1]; aPidl[0] = pidlItem; uint Attrib; Attrib = (uint)ShellApi.SFGAO.SFGAO_FOLDER; int temp; temp = isf.GetAttributesOf(1, aPidl, ref Attrib); // if item is a folder, accept if ((Attrib & (uint)ShellApi.SFGAO.SFGAO_FOLDER) == (uint)ShellApi.SFGAO.SFGAO_FOLDER) { return(0); } // if item is file, check if it has a valid extension for (int i = 0; i < ValidExtension.Length; i++) { if (sDisplay.ToUpper().EndsWith("." + ValidExtension[i].ToUpper())) { return(0); } } return(1); }
public bool DoOperation() { if (Silent) { OperationFlags |= ShellFileOperationFlags.FOF_NOCONFIRMATION; } ShellApi.SHFILEOPSTRUCT FileOpStruct = new ShellApi.SHFILEOPSTRUCT(); FileOpStruct.hwnd = OwnerWindow; FileOpStruct.wFunc = (uint)Operation; String multiSource = StringArrayToMultiString(SourceFiles); String multiDest = StringArrayToMultiString(DestFiles); FileOpStruct.pFrom = Marshal.StringToHGlobalUni(multiSource); FileOpStruct.pTo = Marshal.StringToHGlobalUni(multiDest); FileOpStruct.fFlags = (ushort)OperationFlags; FileOpStruct.lpszProgressTitle = ProgressTitle; FileOpStruct.fAnyOperationsAborted = 0; FileOpStruct.hNameMappings = IntPtr.Zero; int RetVal; RetVal = ShellApi.SHFileOperation(ref FileOpStruct); ShellApi.SHChangeNotify( (uint)ShellChangeNotificationEvents.SHCNE_ALLEVENTS, (uint)ShellChangeNotificationFlags.SHCNF_DWORD, IntPtr.Zero, IntPtr.Zero); if (RetVal != 0) { return(false); } if (FileOpStruct.fAnyOperationsAborted != 0) { return(false); } return(true); }
public bool DoOperation() { ShellApi.SHFILEOPSTRUCT FileOpStruct = new ShellApi.SHFILEOPSTRUCT(); FileOpStruct.hwnd = OwnerWindow; FileOpStruct.wFunc = (uint)Operation; String multiSource = StringArrayToMultiString(SourceFiles); String multiDest = StringArrayToMultiString(DestFiles); FileOpStruct.pFrom = Marshal.StringToHGlobalUni(multiSource); FileOpStruct.pTo = Marshal.StringToHGlobalUni(multiDest); FileOpStruct.fFlags = (ushort)OperationFlags; FileOpStruct.lpszProgressTitle = ProgressTitle; FileOpStruct.fAnyOperationsAborted = 0; FileOpStruct.hNameMappings = IntPtr.Zero; this.NameMappings = new ShellNameMapping[0]; int RetVal; RetVal = ShellApi.SHFileOperation(ref FileOpStruct); if (RetVal != 0) { return(false); } if (FileOpStruct.fAnyOperationsAborted != 0) { return(false); } return(true); }
public static void ClearList() { ShellApi.SHAddToRecentDocs((uint)ShellAddRecentDocs.SHARD_PIDL, IntPtr.Zero); }
public static void AddToList(String path) { ShellApi.SHAddToRecentDocs((uint)ShellAddRecentDocs.SHARD_PATHW, path); }
public bool DoOperation() { ShellApi.SHFILEOPSTRUCT FileOpStruct = new ShellApi.SHFILEOPSTRUCT(); FileOpStruct.hwnd = OwnerWindow; FileOpStruct.wFunc = (uint)Operation; String multiSource = StringArrayToMultiString(SourceFiles); String multiDest = StringArrayToMultiString(DestFiles); FileOpStruct.pFrom = Marshal.StringToHGlobalUni(multiSource); FileOpStruct.pTo = Marshal.StringToHGlobalUni(multiDest); FileOpStruct.fFlags = (ushort)OperationFlags; FileOpStruct.lpszProgressTitle = ProgressTitle; FileOpStruct.fAnyOperationsAborted = 0; FileOpStruct.hNameMappings = IntPtr.Zero; this.NameMappings = new ShellNameMapping[0]; int RetVal; RetVal = ShellApi.SHFileOperation(ref FileOpStruct); ShellApi.SHChangeNotify( (uint)ShellChangeNotificationEvents.SHCNE_ALLEVENTS, (uint)ShellChangeNotificationFlags.SHCNF_DWORD, IntPtr.Zero, IntPtr.Zero); if (RetVal != 0) { throw new Exception("File Operation Failed : Errno " + RetVal); } if (FileOpStruct.fAnyOperationsAborted != 0) { return(false); } // Newly added on 2007/08/29 to make hNameMappings work if (FileOpStruct.hNameMappings != IntPtr.Zero) { // Get MappingTable ShellApi.SHNAMEMAPPINGINDEXSTRUCT mappingIndex = (ShellApi.SHNAMEMAPPINGINDEXSTRUCT)Marshal.PtrToStructure( FileOpStruct.hNameMappings, typeof(ShellApi.SHNAMEMAPPINGINDEXSTRUCT)); // Prepare array this.NameMappings = new ShellNameMapping[mappingIndex.counter]; // Set pointer to first mapping struct IntPtr mover = mappingIndex.firstMappingStruct; for (int i = 0; i < mappingIndex.counter; i++) { ShellApi.SHNAMEMAPPINGSTRUCT oneNameMappingStruct = (ShellApi.SHNAMEMAPPINGSTRUCT)Marshal.PtrToStructure(mover, typeof(ShellApi.SHNAMEMAPPINGSTRUCT)); this.NameMappings[i] = new ShellNameMapping(oneNameMappingStruct.pszOldPath, oneNameMappingStruct.pszNewPath); // move pointer to the next mapping struct mover = (IntPtr)((int)mover + Marshal.SizeOf(typeof(ShellApi.SHNAMEMAPPINGSTRUCT))); } // Free NameMappings in memory ShellApi.SHFreeNameMappings(FileOpStruct.hNameMappings); } return(true); }
public void ShowDialog() { m_FullName = ""; m_DisplayName = ""; // Get shell's memory allocator, it is needed to free some memory later IMalloc pMalloc; pMalloc = ShellFunctions.GetMalloc(); IntPtr pidlRoot; if (RootType == RootTypeOptions.BySpecialFolder) { ShellApi.SHGetFolderLocation(hwndOwner, (int)RootSpecialFolder, UserToken, 0, out pidlRoot); } else // m_RootType = RootTypeOptions.ByPath { uint iAttribute; ShellApi.SHParseDisplayName(RootPath, IntPtr.Zero, out pidlRoot, 0, out iAttribute); } ShellApi.BROWSEINFO bi = new ShellApi.BROWSEINFO(); bi.hwndOwner = hwndOwner; bi.pidlRoot = pidlRoot; bi.pszDisplayName = new String(' ', 256); bi.lpszTitle = Title; bi.ulFlags = (uint)DetailsFlags; bi.lParam = 0; bi.lpfn = new ShellApi.BrowseCallbackProc(this.myBrowseCallbackProc); // Show dialog IntPtr pidlSelected; pidlSelected = ShellApi.SHBrowseForFolder(ref bi); // Save the display name m_DisplayName = bi.pszDisplayName.ToString(); IShellFolder isf = ShellFunctions.GetDesktopFolder(); ShellApi.STRRET ptrDisplayName; isf.GetDisplayNameOf(pidlSelected, (uint)ShellApi.SHGNO.SHGDN_NORMAL | (uint)ShellApi.SHGNO.SHGDN_FORPARSING, out ptrDisplayName); String sDisplay; ShellApi.StrRetToBSTR(ref ptrDisplayName, pidlRoot, out sDisplay); m_FullName = sDisplay; if (pidlRoot != IntPtr.Zero) { pMalloc.Free(pidlRoot); } if (pidlSelected != IntPtr.Zero) { pMalloc.Free(pidlSelected); } Marshal.ReleaseComObject(isf); Marshal.ReleaseComObject(pMalloc); }
private UInt32 RegisterCallbackMessage() { String uniqueMessageString = Guid.NewGuid().ToString(); return(ShellApi.RegisterWindowMessage(uniqueMessageString)); }