Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.net 'Object reference not set to an instance of an object' error

Status
Not open for further replies.

bigjohn9k

Programmer
Dec 17, 2003
4
0
0
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top