I have some code that runs great on 32 bit systems, but when it is running on a 64 bit system I get an error of Invalid Handle.
Here is the code
Dim SA As SECURITY_ATTRIBUTES
Dim retval As Int32
Dim intPort As Int32
Dim intPortPointer As IntPtr
Dim fsOutFile As FileStream
Dim handle As SafeHandle
intPort = CreateFile(strPrinter, GENERIC_WRITE, FILE_SHARE_WRITE, SA, OPEN_EXISTING, 0, 0)
intPortPointer = New IntPtr(intPort) 'convert Integer to IntPtr
handle = New SafeFileHandle(intPortPointer, True)
fsOutFile = New FileStream(handle, FileAccess.Write) 'Create FileStream using Handle
Dim fileWriter As New StreamWriter(fsOutFile)
fileWriter.Write("some stuff")
fileWriter.Flush()
fileWriter.Close()
fsOutFile.Close()
retval = CloseHandle(intPort)
any help is greatly appreciated
Here is the code
Dim SA As SECURITY_ATTRIBUTES
Dim retval As Int32
Dim intPort As Int32
Dim intPortPointer As IntPtr
Dim fsOutFile As FileStream
Dim handle As SafeHandle
intPort = CreateFile(strPrinter, GENERIC_WRITE, FILE_SHARE_WRITE, SA, OPEN_EXISTING, 0, 0)
intPortPointer = New IntPtr(intPort) 'convert Integer to IntPtr
handle = New SafeFileHandle(intPortPointer, True)
fsOutFile = New FileStream(handle, FileAccess.Write) 'Create FileStream using Handle
Dim fileWriter As New StreamWriter(fsOutFile)
fileWriter.Write("some stuff")
fileWriter.Flush()
fileWriter.Close()
fsOutFile.Close()
retval = CloseHandle(intPort)
any help is greatly appreciated