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 shell32, prefix the name with the module name and a period.
<DllImport("shell32.dll", CharSet:=CharSet.Auto, SetLastError:=true, ThrowOnUnmappableChar:=true)> _
Public Function SHFileOperation(<MarshalAs(UnmanagedType.Struct)>ByRef lpFileOp As SHFILEOPSTRUCT) As Integer
End function
VB Signature
Public Declare Function SHFileOperation Lib "shell32" Alias "SHFileOperationA" _
(lpFileOp As SHFILEOPSTRUCT) As Long
Do not use GetLastError with the return values of this function.
It's important that the layout of the SHFILEOPSTRUCT structure differs for 32-bit processes and 64-bit processes.
pTo and pFrom must be end on two \0 characters. As C# strings automatically end one implicit \0 character, another must be added to the end.
Tips & Tricks:
As the struct layout differs between 32-bit and 64-bit processes the struct and method should be defined twice. After checking the current processes bitness call the appropriate version. This is the same approach used by Microsoft in Microsoft.VisualBasic.dll for the FileIO.FileSystem.DeleteFile implementation.
As the struct layout differs between 32-bit and 64-bit processes the struct and method should be defined twice. After checking the current processes bitness call the appropiate version. This is the same approach used by Microsoft in Microsoft.VisualBasic.dll for the FileIO.FileSystem.DeleteFile implementation.
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Auto)]
public struct SHFILEOPSTRUCT32
{
public IntPtr hwnd;
public uint wFunc;
[MarshalAs(UnmanagedType.LPTStr)]
public string pFrom;
[MarshalAs(UnmanagedType.LPTStr)]
public string pTo;
public ushort fFlags;
public bool fAnyOperationsAborted;
public IntPtr hNameMappings;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpszProgressTitle;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct SHFILEOPSTRUCT64
{
public IntPtr hwnd;
public uint wFunc;
[MarshalAs(UnmanagedType.LPTStr)]
public string pFrom;
[MarshalAs(UnmanagedType.LPTStr)]
public string pTo;
public ushort fFlags;
public bool fAnyOperationsAborted;
public IntPtr hNameMappings;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpszProgressTitle;
}
FileFuncFlags - Flags for wFunc member of [SHFILEOPSTRUCT]
2/6/2014 2:40:14 AM - -212.250.153.162
FILEOP_FLAGS - Flags for fFlags member of [SHFILEOPSTRUCT]
2/13/2013 3:55:11 AM - -202.74.138.1
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).