Hello,
GetLastError() also returs a zero value.
Here is the code. The "Integer" had to be changed to "Int32" and the "IsClipboardFormatAvilable" return type was changed to "Boolean" to make it work because when the old VB6 code was checked then that is how "IsClipboardFormatAvailable" was declared there.
//
// Start of file.
//
Function ClipboardHasFile() As Boolean
Dim blnReturn As Boolean
blnReturn = False
#If Not (TargetLinux) then
Soft Declare Function IsClipboardFormatAvailable Lib "user32" (uFormat As Int32) As Boolean
' Decode files in clipboard by reading the names of files
Const CF_HDROP = 15
blnReturn = IsClipboardFormatAvailable(CF_HDROP)
#Else
//
// Linux version
//
#endif
Return blnReturn
//
// End of file.
//
End Function
//
// Start of file.
//
Function ClipboardGetFiles() As String
Dim strFileNameArray() As String
#If Not (TargetLinux) then
Soft Declare Function IsClipboardFormatAvailable Lib "user32" (uFormat As Int32) As Boolean
' Decode files in clipboard by reading the names of files
Const CF_HDROP = 15
//Dim CF_HDROP As UInt32 = 15
Soft Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Int32) As Int32
Soft Declare Function CloseClipboard Lib "user32" () As Int32
Soft Declare Function GetClipboardData Lib "user32" (ByVal wFormat As Int32) As Int32
Soft Declare Function GetLastError Lib "kernel32" () As Int32
' Other required Win32 APIs
Soft Declare Function DragQueryFile Lib "shell32.dll" Alias "DragQueryFileA" (ByVal hDrop As Int32 _
, ByVal UINT As Int32, ByVal lpStr As CString _
, ByVal ch As Int32) As Int32
Dim lngDropHandle As Int32
Dim lngNumFileNames As Int32
Dim strFileName As New MemoryBlock(1024)
Dim lngLoop As Int32
Dim lngError As Int32
' Make sure there is file data.
If ClipboardHasFiles = True Then
' File data exists. Get it.
' Open the clipboard.
If OpenClipboard(0) > 0 Then
' The clipboard is open.
' Get the handle to the dropped list of files.
lngDropHandle = GetClipboardData(CF_HDROP)
If lngDropHandle = 0 Then
lngError = GetLastError()
Else
' Get the number of dropped files.
//lngNumFileNames = DragQueryFile(lngDropHandle, -1, vbNullString, 0)
lngNumFileNames = DragQueryFile(lngDropHandle, -1, "", 0)
' Get the file names.
ReDim strFileNameArray(lngNumFileNames)
For lngLoop = 0 To lngNumFileNames-1
' Get the file name.
Call DragQueryFile( lngDropHandle, lngLoop - 1, _
strFileName, strFileName.Len)
' Truncate at the NULL character.
//strFileNameArray(lngLoop) = Left$(strFileName, InStr(strFileName, vbNullChar) - 1)
strFileNameArray.Append(strFileName.WString(0))
Next
End If
' Close the clipboard.
Call CloseClipboard
End If
End If
#Else
//
// Linux Version
//
#Endif
Return strFileNameArray
//
// End of file.
//
End Function
Thanks and Regards,
Shahid.