Following code is giving me an 'Object reference not set to an instance of an object' error on SHFileOperation(x) line.
Any suggestion is appreciated.
Private Const FO_COPY = &H2
Private Const FOF_SIMPLEPROGRESS = &H100
Private Const FOF_NOCONFIRMATION = &H10
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" _
(ByVal lpFileOp As SHFILEOPSTRUCT) As Long
Structure SHFILEOPSTRUCT
Public hWnd As Long
Public wFunc As Long
Public pFrom As String
Public pTo As String
Public fFlags As Integer
Public fAnyOperationsAborted As Boolean
Public hNameMappings As Long
Public lpszProgressTitle As String
End Structure
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x As SHFILEOPSTRUCT
'Dim y As New shFileOperation()
x.pFrom = "C:\winzip.log"
x.pTo = "l:\winzip.log"
x.fFlags = FOF_NOCONFIRMATION
x.wFunc = FO_COPY
SHFileOperation(x)
MsgBox("Copy Complete.", vbOKOnly)
End Sub
Any suggestion is appreciated.
Private Const FO_COPY = &H2
Private Const FOF_SIMPLEPROGRESS = &H100
Private Const FOF_NOCONFIRMATION = &H10
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" _
(ByVal lpFileOp As SHFILEOPSTRUCT) As Long
Structure SHFILEOPSTRUCT
Public hWnd As Long
Public wFunc As Long
Public pFrom As String
Public pTo As String
Public fFlags As Integer
Public fAnyOperationsAborted As Boolean
Public hNameMappings As Long
Public lpszProgressTitle As String
End Structure
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x As SHFILEOPSTRUCT
'Dim y As New shFileOperation()
x.pFrom = "C:\winzip.log"
x.pTo = "l:\winzip.log"
x.fFlags = FOF_NOCONFIRMATION
x.wFunc = FO_COPY
SHFileOperation(x)
MsgBox("Copy Complete.", vbOKOnly)
End Sub