MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.
Dim InpFile As String Dim OutFile As String Dim hFile As Long Dim fileStruct As OFSTRUCT Dim FSize As Long Dim BytesRead As Long Dim BytesWritten As Long Dim hMem As Long Dim lpMem As Long Dim r As Long Dim bts As Byte InpFile = "input.txt" OutFile = "OUTPUT.txt" 'Get the size of the file to be read FSize = FileLen(InpFile) If FSize > 0 Then 'Allocate a block of memory equal to the size of the input file. 'hMem = GlobalAlloc(GMEM_ZEROINIT, FSize) hMem = GlobalAlloc(GPTR, FSize) If hMem <> 0 Then lpMem = GlobalLock(hMem) 'Read the file into memory hFile = OpenFile(InpFile, fileStruct, OF_READ Or _ OF_SHARE_DENY_NONE) BytesRead = hread(hFile, ByVal lpMem, FSize) MsgBox Format(BytesRead) & " bytes read into memory" r = lclose(hFile) 'Write the file back to disk to verify the file was 'read correctly hFile = OpenFile(OutFile, fileStruct, OF_CREATE Or _ OF_WRITE Or OF_SHARE_DENY_NONE) BytesWritten = hwrite(hFile, ByVal lpMem, FSize) MsgBox Format(BytesWritten) & " bytes written to output file" r = lclose(hFile) 'Free resources r = GlobalUnlock(hMem) r = GlobalFree(hMem) Else MsgBox "Not enough memory to store file" End If Else MsgBox "Input file is zero bytes in length" End If End
|I Need help preventing my button click event from being raised twice on my VB.Net application||6||78|
|Adding to a VBA?||6||69|
|MS Date Picker 64 bit 32 bit issue||12||53|
|Convert VB6 MSXML2.ServerXMLHTTP process to C#||2||46|
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
11 Experts available now in Live!