Results 1 to 3 of 3

Thread: Setting flags for SHFileOperation

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Sydney Australia
    Posts
    804
    Thanks Parksie, that worked!

    One more thing, how can I read errors I get back from API call?

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Look up the FormatMessage function, and the details pertaining to FORMAT_MESSAGE_FROM_SYSTEM.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Sydney Australia
    Posts
    804
    Will this do the trick?

    Code:
    Declare Function FormatMessage Lib "kernel32" Alias "FormatMessageA" _
    (ByVal dwFlags As Long, lpSource As Any, ByVal dwMessageId As Long, ByVal dwLanguageId As Long, _
    ByVal lpBuffer As String, ByVal nSize As Long, Arguments As Long) As Long
      
    Public Const FORMAT_MESSAGE_ALLOCATE_BUFFER = &H100
    Public Const FORMAT_MESSAGE_ARGUMENT_ARRAY = &H2000
    Public Const FORMAT_MESSAGE_FROM_HMODULE = &H800
    Public Const FORMAT_MESSAGE_FROM_STRING = &H400
    Public Const FORMAT_MESSAGE_FROM_SYSTEM = &H1000
    Public Const FORMAT_MESSAGE_IGNORE_INSERTS = &H200
    Public Const FORMAT_MESSAGE_MAX_WIDTH_MASK = &HFF
    Public Const LANG_USER_DEFAULT = &H400&
    
    Function GetLastErrorStr(dwErrCode As Long) As String
      Static sMsgBuf As String * 257, dwLen As Long
      dwLen = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM _
      Or FORMAT_MESSAGE_IGNORE_INSERTS Or FORMAT_MESSAGE_MAX_WIDTH_MASK, ByVal 0&, _
      dwErrCode, LANG_USER_DEFAULT, ByVal sMsgBuf, 256&, 0&)
      If dwLen Then GetLastErrorStr = Left$(sMsgBuf, dwLen)
    End Function
    called:
    Code:
    Dim x
    x = GetLastErrorStr(Val(Text1.Text))
    Label1.Caption = x

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width