Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than Structures, prefix the name with the module name and a period.
SHFILEOPSTRUCT (Structures)
.
C# Definition:
//[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
//If u use the above u may incounter an invalid memory access exception (when use ansi)
//or see nothing (when use unicode)when u use FOF_SIMPLEPROGRESS flag.
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode, Pack=1)]
struct SHFILEOPSTRUCT
{
public IntPtr hwnd;
public FILEOP_FLAGS wFunc;
[MarshalAs(UnmanagedType.LPWStr)]
public string pFrom;
[MarshalAs(UnmanagedType.LPWStr)]
public string pTo;
public ushort fFlags;
//typedef int BOOL; (in platform SDK)
//BOOL fAnyOperationsAborted; (in platform SDK)
//public bool fAnyOperationsAborted;
public Int32 fAnyOperationsAborted;
public IntPtr hNameMappings;
[MarshalAs(UnmanagedType.LPWStr)]
public string lpszProgressTitle;
}
VB Definition:
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> _
Public Structure SHFILEOPSTRUCT
Public hwnd As IntPtr
Public wFunc As FO_Func
<MarshalAs(UnmanagedType.LPWStr)> _
Public pFrom As String
<MarshalAs(UnmanagedType.LPWStr)> _
Public pTo As String
Public fFlags As FILEOP_FLAGS
Public fAnyOperationsAborted As Boolean
Public hNameMappings As IntPtr
<MarshalAs(UnmanagedType.LPWStr)> _
Public lpszProgressTitle As String ' only used if FOF_SIMPLEPROGRESS
End Structure
User-Defined Field Types:
FILEOP_FLAGS
Notes:
I tried to use this to send files to the recycle bin. It failed (Marshal.GetLastWin32Error was 6, invalid handle) and sometimes threw a NullReferenceException. To make it work I did the following;
Always set hwnd to my main app window (I was using IntPtr.Zero, this might not be required)
Correctly treat pTo and pFrom as zero delimited double zero terminated.
In my case I only needed pTo so I just added a null byte to the end and used Marshal.StringToHGlobalUni() to set the value
Failure on 64 bit OS
Under x64, the SHFILEOPSTRUCT must be declared without the Pack = 1 parameter, or it will fail. This is a real pain if you want your code to be platform independent, as you have to declare two separate structures, one with Pack = 1, and one without. You then have to declare two different SHFileOperation calls, one for each of the structures. Then you have to decide which one to call depending on whether you are running on 32 or 64 bit.
An IntPtr is a pointer to a memory location (unmanaged) that adapts to the platform it is running on (64-bit, etc.) UNLIKE a standard int/Integer. You should always use this type for unmanaged calls that require it, even though an int will appear to work on your development machine.
1/13/2008 4:00:13 AM - Damon Carr-72.43.165.29
An IntPtr is a pointer to a memory location (unmanaged) that adapts to the platform it is running on (64-bit, etc.) UNLIKE a standard int/Integer. You should always use this type for unmanaged calls that require it, even though an int will appear to work on your development machine.
1/13/2008 4:00:13 AM - Damon Carr-72.43.165.29
The SHFileOperation API
3/5/2023 2:08:07 PM - Quaint Mako-88.174.61.36
Please edit this page!
Do you have...
helpful tips?
corrections to the existing content?
alternate definitions?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing any supporting types needed.