FOF_NO_UI Constant
|
|
Thread rating:  |
GeoffG - 12 Mar 2008 01:47 GMT 1. What is the hex value of the FOF_NO_UI constant? The constant is listed on: http://msdn2.microsoft.com/en-us/library/bb759795(VS.85).aspx
2. Where should I look for a list of Win32 API constant values on the Microsoft website?
Thanks Geoff
Karl E. Peterson - 12 Mar 2008 02:00 GMT > 1. What is the hex value of the FOF_NO_UI constant? > The constant is listed on: > http://msdn2.microsoft.com/en-us/library/bb759795(VS.85).aspx No idea.
> 2. Where should I look for a list of Win32 API constant values on the > Microsoft website? You'll need to download and install the Vista SDK here:
http://msdn2.microsoft.com/en-us/windowsvista/aa904955.aspx
Search the header (*.h) files for unknown constants.
 Signature .NET: It's About Trust! http://vfred.mvps.org
Karl E. Peterson - 12 Mar 2008 02:30 GMT > 1. What is the hex value of the FOF_NO_UI constant? > The constant is listed on: > http://msdn2.microsoft.com/en-us/library/bb759795(VS.85).aspx Okay, I installed the friggin Vista SDK, and was right -- it's there. This is indented, to highlight wordwrap:
// SHFILEOPSTRUCT.fFlags and IFileOperation::SetOperationFlags() flag values
#define FOF_MULTIDESTFILES 0x0001 #define FOF_CONFIRMMOUSE 0x0002 #define FOF_SILENT 0x0004 // don't display progress UI (confirm prompts may be displayed still) #define FOF_RENAMEONCOLLISION 0x0008 // automatically rename the source files to avoid the collisions #define FOF_NOCONFIRMATION 0x0010 // don't display confirmation UI, assume "yes" for cases that can be bypassed, "no" for those that can not #define FOF_WANTMAPPINGHANDLE 0x0020 // Fill in SHFILEOPSTRUCT.hNameMappings // Must be freed using SHFreeNameMappings #define FOF_ALLOWUNDO 0x0040 // enable undo including Recycle behavior for IFileOperation::Delete() #define FOF_FILESONLY 0x0080 // only operate on the files (non folders), both files and folders are assumed without this #define FOF_SIMPLEPROGRESS 0x0100 // means don't show names of files #define FOF_NOCONFIRMMKDIR 0x0200 // don't dispplay confirmatino UI before making any needed directories, assume "Yes" in these cases #define FOF_NOERRORUI 0x0400 // don't put up error UI, other UI may be displayed, progress, confirmations #if (_WIN32_IE >= 0x0500) #define FOF_NOCOPYSECURITYATTRIBS 0x0800 // dont copy file security attributes (ACLs) #define FOF_NORECURSION 0x1000 // don't recurse into directories for operations that would recurse #define FOF_NO_CONNECTED_ELEMENTS 0x2000 // don't operate on connected elements ("xxx_files" folders that go with .htm files) #define FOF_WANTNUKEWARNING 0x4000 // during delete operation, warn if nuking instead of recycling (partially overrides FOF_NOCONFIRMATION) #endif // (_WIN32_IE >= 0x500) #if (_WIN32_WINNT >= 0x0501) #define FOF_NORECURSEREPARSE 0x8000 // deprecated; the operations engine always does the right thing on FolderLink objects (symlinks, reparse points, folder shortcuts) #endif // (_WIN32_WINNT >= 0x501) #define FOF_NO_UI (FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR) // don't display any UI at all
> 2. Where should I look for a list of Win32 API constant values on the > Microsoft website? You need a good tool that can search all the files in a directory. (I use TextPad.) Install the SDK, then search the "headers" folder. The Vista SDK can be found here:
http://msdn2.microsoft.com/en-us/windowsvista/aa904955.aspx
This is definitely a different beast than the PlatformSDK, which is more geared towards XP/2003, and less towards .NET:
http://www.microsoft.com/downloads/details.aspx?FamilyId=A55B6B43-E24F-4EA3-A93E -40C0EC4F68E5&displaylang=en
Later... Karl
 Signature .NET: It's About Trust! http://vfred.mvps.org
GeoffG - 13 Mar 2008 02:37 GMT Karl: Very many thanks. The prospect of downloading up to 1000+ Mb on a flakey broadband connection didn't fill me with joy, especially as I'm really only wanting an updated version of the WIN32API.TXT file. So, I'm grateful to you.
Does the following line:
> #define FOF_NO_UI (FOF_SILENT | FOF_NOCONFIRMATION | > FOF_NOERRORUI | FOF_NOCONFIRMMKDIR) // don't display any UI at all mean that the value of FOF_NO_UI is 0x0614? That is, the sum of:
FOF_SILENT (0x0004) + FOF_NOCONFIRMATION (0x0010) + FOF_NOERRORUI (0x0400) + FOF_NOCONFIRMMKDIR (0x0200)
Many thanks Geoff
>> 1. What is the hex value of the FOF_NO_UI constant? >> The constant is listed on: [quoted text clipped - 64 lines] > > Later... Karl MikeD - 13 Mar 2008 02:54 GMT > Karl: > Very many thanks. [quoted text clipped - 11 lines] > FOF_SILENT (0x0004) + FOF_NOCONFIRMATION (0x0010) + FOF_NOERRORUI (0x0400) > + FOF_NOCONFIRMMKDIR (0x0200) Not exactly. Those are bitmasks, so you OR them rather than ADD them.
 Signature Mike Microsoft MVP Visual Basic
GeoffG - 13 Mar 2008 11:23 GMT Mike: Many thanks. Not being familiar with C, I thought the puzzling code line was probably a bit mask constructed from the other values. Thanks for confirming.
I had wondered what value I should give the FOF_NO_UI constant when declaring it in VBA and it seems 1556 (&H614 or 0x0614) is the value, as in: Private Const FOF_NO_UI = &H614
However, I've now chosen not to hard-code the value as explained below. My remaining questions are: is this approach OK and are the strings OK.
I've used two Enums (FileOperations and FileOperationFlags) when declaring the wFunc and fFlags members of the SHFILEOPSTRUCT structure (as shown below). The FileOperationFlags Enum uses its own constants to declare the FOF_NO_UI constant (instead of hard-coding it to &H614). (I think it's neat that you can do this.)
The Enums work well when giving values to the wFunc and fFlags members, as the choices appear in an intellisense list. (I assume the structure declaration is OK as Enums use long integers and the members would otherwise be declared as longs.)
The other interesting fact is that VB seems automatically to take care of terminating the strings with two Null characters. Is VB doing this when translating from Unicode to ANSI? Or am I just being lucky and sooner or later it'll blow up?
Incidentally, below, I've copied the notes on each member from the Microsoft web site (as I need reminders when I revisit this).
' Declare Win32 API function to copy, move, ' delete, or rename files: Private Declare Function SHFileOperation Lib "Shell32.dll" _ Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
' Declare the structure to be used with API function: Private Type SHFILEOPSTRUCT
' A window handle to the dialog box to display ' information about the status of the file operation: hwnd As Long
' A value that indicates which operation to perform; ' one of the values in the FileOperations Enum: wFunc As FileOperations
' Note: This string must be double-null terminated. ' A pointer to one or more source file names. ' These names should be fully-qualified paths to prevent ' unexpected results. Standard Microsoft MS-DOS wildcard ' characters, such as "*", are permitted only in the ' file-name position. Using a wildcard character ' elsewhere in the string will lead to unpredictable results. ' Although this member is declared as a single ' null-terminated string, it is actually a buffer that can ' hold multiple null-delimited file names. Each file name ' is terminated by a single NULL character. The last file ' name is terminated with a double NULL character ("\0\0") ' to indicate the end of the buffer: pFrom As String
' Note: This string must be double-null terminated. ' A pointer to the destination file or directory name. ' This parameter must be set to NULL if it is not used. ' Wildcard characters are not allowed. Their use will ' lead to unpredictable results. ' Like pFrom, the pTo member is also a double-null ' terminated string and is handled in much the same way. ' However, pTo must meet the following specifications: ' - Wildcard characters are not supported. ' - Copy and Move operations can specify destination ' directories that do not exist. In those cases, ' the system attempts to create them and normally ' displays a dialog box to ask the user if they ' want to create the new directory. To suppress ' this dialog box and have the directories created ' silently, set the FOF_NOCONFIRMMKDIR flag in fFlags. ' - For Copy and Move operations, the buffer can contain ' multiple destination file names if the fFlags ' member specifies FOF_MULTIDESTFILES. ' - Pack multiple names into the pTo string in the same ' way as for pFrom. ' - Use fully-qualified paths. Using relative paths is ' not prohibited, but can have unpredictable results. pTo As String
' Flags that control the file operation; ' the constants that can be used in combination ' in this member are enumerated in the ' FileOperationFlags enum: fFlags As FileOperationFlags
' When the function returns, this member contains ' TRUE if any file operations were aborted before ' they were completed; otherwise, FALSE. ' An operation can be manually aborted by the user ' through UI or it can be silently aborted by the ' system if the FOF_NOERRORUI or FOF_NOCONFIRMATION ' flags were set: fAnyOperationsAborted As Long
' When the function returns, this member contains a ' handle to a name mapping object that contains the ' old and new names of the renamed files. This member ' is used only if the fFlags member includes the ' FOF_WANTMAPPINGHANDLE flag. See Remarks for more details: hNameMappings As Long
' A pointer to the title of a progress dialog box. ' This is a null-terminated string. This member is ' used only if fFlags includes the FOF_SIMPLEPROGRESS ' flag: lpszProgressTitle As String
End Type
' Declare enumeration of FILE OPERATION constants, ' for use with the wFunc member of the structure: Private Enum FileOperations
' Move the files specified in pFrom to the ' location specified in pTo: FO_MOVE = &H1
' Copy the files specified in the pFrom member ' to the location specified in the pTo member: FO_COPY = &H2
' Delete the files specified in pFrom: FO_DELETE = &H3
' Rename the file specified in pFrom. ' You cannot use this flag to rename multiple ' files with a single function call. Use ' FO_MOVE instead: FO_RENAME = &H4
End Enum
' Declare enumeration of FILE OPERATION FLAG constants, ' for use with the fFlags member of the structure; ' flags can be used in combination using OR: Private Enum FileOperationFlags
' The pTo member specifies multiple destination files ' (one for each source file in pFrom) rather than one ' directory where all source files are to be deposited: FOF_MULTIDESTFILES = &H1
' Not used: FOF_CONFIRMMOUSE = &H2
' Do not display a progress dialog box: FOF_SILENT = &H4
' Give the file being operated on a new name ' in a move, copy, or rename operation if a file ' with the target name already exists at the destination: FOF_RENAMEONCOLLISION = &H8
' Respond with Yes to All for any dialog box that is ' displayed: FOF_NOCONFIRMATION = &H10
' If FOF_RENAMEONCOLLISION is specified and any files ' were renamed, assign a name mapping object that ' contains their old and new names to the ' hNameMappings member. This object must be freed ' using SHFreeNameMappings when it is no longer needed: FOF_WANTMAPPINGHANDLE = &H20
' Preserve undo information, if possible. Operations ' can be undone only from the same process that ' performed the original operation. If, despite ' earlier warnings against doing so, pFrom does not ' contain fully-qualified path and file names, ' this flag is ignored: FOF_ALLOWUNDO = &H40
' Perform the operation only on files (not on folders) ' if a wildcard file name (*.*) is specified: FOF_FILESONLY = &H80
' Display a progress dialog box but do not show ' individual file names as they are operated on: FOF_SIMPLEPROGRESS = &H100
' Do not ask the user to confirm the creation of a new ' directory if the operation requires one to be created: FOF_NOCONFIRMMKDIR = &H200
' Do not display a dialog to the user if an error occurs: FOF_NOERRORUI = &H400
' Only perform the operation in the local directory. ' Don't operate recursively into subdirectories, ' which is the default behavior: FOF_NORECURSION = &H1000
' Version 4.71. Do not copy the security attributes ' of the file. The destination file receives the ' security attributes of its new folder: FOF_NOCOPYSECURITYATTRIBS = &H800
' Version 5.0. Do not move connected files as a group. ' Only move the specified files: FOF_NO_CONNECTED_ELEMENTS = &H2000
' Version 5.0. Send a warning if a file is being ' permanently destroyed during a delete operation ' rather than recycled. This flag partially overrides ' FOF_NOCONFIRMATION: FOF_WANTNUKEWARNING = &H4000
' Not used: FOF_NORECURSEREPARSE = &H8000&
' Version 6.0.6060 (Windows Vista). ' Perform the operation silently, presenting no user ' interface (UI) to the user. This is equivalent to ' FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | ' FOF_NOCONFIRMMKDIR. FOF_NO_UI = FOF_SILENT Or FOF_NOCONFIRMATION Or FOF_NOERRORUI Or FOF_NOCONFIRMMKDIR
End Enum
Thanks for any further assistance. Regards Geoff
>> Karl: >> Very many thanks. [quoted text clipped - 13 lines] > > Not exactly. Those are bitmasks, so you OR them rather than ADD them. GeoffG - 15 Mar 2008 10:46 GMT If anyone can offer further enlightenment on the question of passing VB strings to the pFrom and pTo members of the SHFILEOPSTRUCT structure, I'd be grateful.
One of my textbooks ("Win32 API Programming with Visual Basic" by Dr Steven Roman, page 458), appears to take no action to terminate the strings with two Null characters, yet as mentioned in the post below, the call to SHFileOperation works.
Any thoughts please?
Regards Geoff
> Mike: > Many thanks. [quoted text clipped - 247 lines] >> >> Not exactly. Those are bitmasks, so you OR them rather than ADD them. Thorsten Albers - 15 Mar 2008 11:37 GMT GeoffG <geoffcg@nonospam.com> schrieb im Beitrag <eU1dEHohIHA.3788@TK2MSFTNGP03.phx.gbl>...
> If anyone can offer further enlightenment on the question of passing VB > strings to the pFrom and pTo members of the SHFILEOPSTRUCT structure, I'd be > grateful. > One of my textbooks ("Win32 API Programming with Visual Basic" by Dr Steven > Roman, page 458), appears to take no action to terminate the strings with
> two Null characters, yet as mentioned in the post below, the call to > SHFileOperation works. When VB converts a VB string to an ANSI string internally it automatically makes it a NULL terminated string. Actually a VB (i.e. OLE length prefixed) string is also NULL terminated but the terminating NULL character here is not used to calculate the string length, etc.
 Signature ---------------------------------------------------------------------- THORSTEN ALBERS Universität Freiburg albers@ uni-freiburg.de ----------------------------------------------------------------------
GeoffG - 17 Mar 2008 23:34 GMT Thorsten: Many thanks for your reply. Yes, I did know that VB stores strings in the BSTR format and converts them from Unicode to null-terminated ANSI strings when calling the ANSI version of an external function. I should have emphasised the word *two* null characters in my earlier post to make clearer the point I was enquirying about. I'm considering Stuart's response at this stage, but, at this stage, would still confess to being somewhat mystified! Many thanks again. Geoff
> GeoffG <geoffcg@nonospam.com> schrieb im Beitrag > <eU1dEHohIHA.3788@TK2MSFTNGP03.phx.gbl>... [quoted text clipped - 14 lines] > string is also NULL terminated but the terminating NULL character here is > not used to calculate the string length, etc. Thorsten Albers - 18 Mar 2008 01:32 GMT GeoffG <geoffcg@nonospam.com> schrieb im Beitrag <u8BPN8HiIHA.2416@TK2MSFTNGP04.phx.gbl>...
> I should have emphasised the word *two* null > characters in my earlier post to make clearer the point I was enquirying > about. I'm considering Stuart's response at this stage, but, at this stage, > would still confess to being somewhat mystified! No, its my fault: I should have read you posting more careful...
> One of my textbooks ("Win32 API Programming with Visual Basic" by Dr Steven
> Roman, page 458), appears to take no action to terminate the strings with
> two Null characters, yet as mentioned in the post below, the call to > SHFileOperation works. > Any thoughts please? Even if no second NULL character is appended to the string the API function will read this character since it has >no information on the count< of string characters passed. If the calling process has not allocated the memory following the memory allocated for the string, the process here is very likely to crash. If it has allocated the memory it depends on its contents: If the first byte of the allocated memory following the memory allocated for the string :-) happens to be a NULL byte, the API function will perform its task as expected. It is not very unlikely that this byte is a NULL byte but one really shouldn't rely on this... In other words: It is lucky chance, if the API function call succeeds without an additional NULL character appended to the string.
 Signature ---------------------------------------------------------------------- THORSTEN ALBERS Universität Freiburg albers@ uni-freiburg.de ----------------------------------------------------------------------
Stuart McCall - 15 Mar 2008 19:16 GMT > If anyone can offer further enlightenment on the question of passing VB > strings to the pFrom and pTo members of the SHFILEOPSTRUCT structure, I'd [quoted text clipped - 9 lines] > Regards > Geoff <SNIP>
PMFJI. Here's the Execute method of my FileOps class. This has been in use for about 4 years.
''' BEGIN CODE '''
Public Sub Execute() Dim Buffer() As Byte 'Byte array used as buffer Dim buflen As Long 'Stores length of buffer Dim fop As SHFILEOPSTRUCT 'Stores file operation info Dim v As Variant 'Scratch counter
'****************************************************** buflen = LenB(fop) 'Binary length of struct ReDim Buffer(1 To buflen) 'Size Buffer accordingly '******************************************************
'Fill the struct With fop .hWnd = m_hWnd .wFunc = m_Func If m_Caption <> "" Then 'Flags must contain FOF_SIMPLEPROGRESS 'for the caption to be displayed m_Flags = m_Flags Or FOF_SIMPLEPROGRESS .lpszProgressTitle = m_Caption & DELIM & DELIM End If .fFlags = m_Flags For Each v In FromList .pFrom = .pFrom & v & DELIM Next .pFrom = .pFrom & DELIM For Each v In ToList .pTo = .pTo & v & DELIM Next .pTo = .pTo & DELIM End With
'****************************************************** ' Copy the struct into the byte array CopyMemory Buffer(1), fop, buflen ' Shuffle the last 12 bytes up by 2 to byte-align the data CopyMemory Buffer(19), Buffer(21), 12 '******************************************************
'Call the api, passing a pointer to the byte array m_ReturnCode = SHFileOperation(Buffer(1))
'****************************************************** 'Shuffle the 12 bytes back down by 2 bytes CopyMemory Buffer(21), Buffer(19), 12 'Copy the byte array back into the struct CopyMemory fop, Buffer(1), buflen '******************************************************
If m_ReturnCode <> 0 Then ' Operation failed m_ErrorCode = Err.LastDllError m_AnyOperationsAborted = (fop.fAnyOperationsAborted <> 0) End If End Sub ''' END CODE '''
DELIM is a const, declared as vbNullChar. FromList and ToList are collections, where I gather the file paths. As you can see, I build the strings with a trailing DELIM for each entry, then when the loop terminates I append another.
I posted the whole procedure in case you weren't aware of the byte-alignment issue with the SHFILEOPSTRUCT structure (VB structure members are word-aligned).
Stuart McCall - 18 Mar 2008 01:59 GMT Oops. Addendum:
(VB structure members are word-aligned)
should have read:
(VB structure members are Dword-aligned)
GeoffG - 19 Mar 2008 04:15 GMT Stuart: Very many thanks for your reply and code. I have been wondering why your code shuffles up data from the 21st to the 19th byte. Have you declared fFlags as an integer and is this the reason? Regards Geoff
> Oops. Addendum: > [quoted text clipped - 3 lines] > > (VB structure members are Dword-aligned) Stuart McCall - 25 Mar 2008 02:49 GMT > Stuart: > Very many thanks for your reply and code. > I have been wondering why your code shuffles up data from the 21st to the > 19th byte. Have you declared fFlags as an integer and is this the reason? > Regards > Geoff Hi Geoff
Sorry for the late reply. Been in hospital for a few days (quite a regular occurrence with me).
Yes I have fFlags declared as int. That's how I found it in winapi.txt. Do you have it declared as a Long? I'm pretty sure I tried that when first experimenting with SHFileOperation and the 3 members below fFlags weren't passed properly. As luck would have it, they're not the most useful of the struct members and most times you won't miss 'em, but I once had occasion to need fAborted and couldn't get it to work. So I researched (ie googled :) and came up with the byte-shuffle, which works just fine.
Do you have a working module now?
Regards Stuart
GeoffG - 27 Mar 2008 09:25 GMT Hi Stuart,
I'm very glad you're still contributing to this thread and I hope you're feeling better.
I'm drafting a reply, but may not be able to finish it until next week. Keep watching please!
Regards Geoff
>> Stuart: >> Very many thanks for your reply and code. [quoted text clipped - 21 lines] > Regards > Stuart PeterD - 13 Mar 2008 14:38 GMT >> Karl: >> Very many thanks. [quoted text clipped - 13 lines] > >Not exactly. Those are bitmasks, so you OR them rather than ADD them. Except for carry, OR and add are functionally the same. Yes, 0x0614 is the correct result.
GeoffG - 15 Mar 2008 10:46 GMT Peter: Many thanks for confirmation. Geoff
>>> Karl: >>> Very many thanks. [quoted text clipped - 19 lines] > Except for carry, OR and add are functionally the same. Yes, 0x0614 is > the correct result. Karl E. Peterson - 13 Mar 2008 17:18 GMT > The prospect of downloading up to 1000+ Mb on a flakey broadband connection > didn't fill me with joy, especially as I'm really only wanting an updated > version of the WIN32API.TXT file. So, I'm grateful to you. Yeah, I've always thought it'd be very nice to have the ability to simply download the latest header files. I've never found an authorized way to do that, unfortunately.
 Signature .NET: It's About Trust! http://vfred.mvps.org
GeoffG - 15 Mar 2008 10:48 GMT Karl: I've spent some time today searching the Microsoft website for an updated WIN32API.TXT file - with no luck. It looks like this useful text file was shipped with the Office 97 and Office 2000 Developer CDs, but has since fizzled out. Pity...
Many thanks again for your help. Geoff
>> The prospect of downloading up to 1000+ Mb on a flakey broadband >> connection [quoted text clipped - 4 lines] > download the latest header files. I've never found an authorized way to > do that, unfortunately.
|
|
|