Click here to Skip to main content
15,923,222 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Security Question on a Windows Service Pin
Robert Rohde11-Jan-05 2:54
Robert Rohde11-Jan-05 2:54 
GeneralRe: Security Question on a Windows Service Pin
KreativeKai11-Jan-05 6:22
professionalKreativeKai11-Jan-05 6:22 
GeneralRe: Security Question on a Windows Service Pin
Dave Kreskowiak11-Jan-05 5:40
mveDave Kreskowiak11-Jan-05 5:40 
GeneralRe: Security Question on a Windows Service Pin
KreativeKai11-Jan-05 5:57
professionalKreativeKai11-Jan-05 5:57 
GeneralRe: Security Question on a Windows Service Pin
Dave Kreskowiak11-Jan-05 9:07
mveDave Kreskowiak11-Jan-05 9:07 
Generaldate show Pin
Makniteasy10-Jan-05 21:09
Makniteasy10-Jan-05 21:09 
GeneralRe: date show Pin
Gavin Jeffrey10-Jan-05 22:40
Gavin Jeffrey10-Jan-05 22:40 
GeneralReadFile not working in VB.NET Pin
Roman Nurik10-Jan-05 20:00
Roman Nurik10-Jan-05 20:00 
Hey, i am trying to figure out why ReadFile isn't working the way it should in VB.NET. The problem is that I call ReadFile on some file that i open with CreateFile, and it fills a buffer with the first couple of bytes from the file.. that is fine. but when i call ReadFile again, it still returns the same first bytes.. as if it didnt increment the file pointer. Then, i tried checking the file pointer value before and after each call to readfile.. and what seems to happen is that every time readfile is called, the file pointer is reset to 0, because after the first, or second call to readfile the file pointer is correct (the number of bytes i read using the function).. so i guess it gets reset to 0 before it fills the buffer.

here is the code if anyone can help:

<br />
Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, ByRef lpSecurityAttributes As SECURITY_ATTRIBUTES, ByVal dwCreationDisposition As Integer, ByVal dwFlagsAndAttributes As Integer, ByVal hTemplateFile As Integer) As Integer<br />
<br />
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Integer) As Integer<br />
<br />
Declare Function ReadFile Lib "kernel32" (ByVal hFile As Integer, ByVal destBuffer() As Byte, ByVal nNumberOfBytesToRead As Integer, ByRef lpNumberOfBytesRead As Integer, ByRef lpOverlapped As OVERLAPPED) As Integer<br />
<br />

...
<br />
<br />
Dim hDisk As Integer<br />
Dim bytesReturned As Integer<br />
<br />
hDisk = CreateFile("E:\somebigfile.dat", _<br />
	GENERIC_READ, FILE_SHARE_READ Or FILE_SHARE_WRITE, _<br />
	Nothing, OPEN_EXISTING, 0, 0)<br />
<br />
If hDisk = INVALID_HANDLE_VALUE Then Exit Sub<br />
<br />
me.Text = SetFilePointer(hDisk, 0, Nothing, FILE_CURRENT)<br />
<br />
Dim dest() As Byte<br />
ReDim dest(1023)<br />
Dim destLen As Integer = dest.Length<br />
<br />
ReadFile(hDisk, dest, 1024, bytesReturned, Nothing)<br />
PrintData(dest, txt1) 'just a function that writes the data to a textbox txt1<br />
<br />
me.Text &= "  " & SetFilePointer(hDisk, 0, Nothing, FILE_CURRENT)<br />
<br />
ReadFile(hDisk, dest, 1024, bytesReturned, Nothing)<br />
PrintData(dest, txt2)<br />
<br />
me.Text &= "  " & SetFilePointer(hDisk, 0, Nothing, FILE_CURRENT)<br />
<br />
ReadFile(hDisk, dest, 1024, bytesReturned, Nothing)<br />
PrintData(dest, txt3)<br />


Thank you for any help!!!! This is driving me nuts!!!


r -

GeneralRe: ReadFile not working in VB.NET Pin
Dave Kreskowiak11-Jan-05 5:32
mveDave Kreskowiak11-Jan-05 5:32 
GeneralRe: ReadFile not working in VB.NET Pin
Roman Nurik11-Jan-05 5:38
Roman Nurik11-Jan-05 5:38 
QuestionHow to set the first parameter of URLDownlofToFIle() in VB. Pin
girijaa10-Jan-05 18:50
professionalgirijaa10-Jan-05 18:50 
AnswerRe: How to set the first parameter of URLDownlofToFIle() in VB. Pin
Dave Kreskowiak11-Jan-05 4:31
mveDave Kreskowiak11-Jan-05 4:31 
GeneralRe: How to set the first parameter of URLDownlofToFIle() in VB. Pin
girijaa11-Jan-05 18:10
professionalgirijaa11-Jan-05 18:10 
GeneralRe: How to set the first parameter of URLDownlofToFIle() in VB. Pin
Dave Kreskowiak12-Jan-05 1:10
mveDave Kreskowiak12-Jan-05 1:10 
GeneralRe: How to set the first parameter of URLDownlofToFIle() in VB. Pin
Dave Kreskowiak13-Jan-05 1:55
mveDave Kreskowiak13-Jan-05 1:55 
GeneralAdd nodes to Treeview Pin
vilasjain10-Jan-05 17:33
vilasjain10-Jan-05 17:33 
GeneralRe: Add nodes to Treeview Pin
Robert Rohde10-Jan-05 20:42
Robert Rohde10-Jan-05 20:42 
GeneralCreating the Treeview nodes dynamically Pin
vilasjain10-Jan-05 17:30
vilasjain10-Jan-05 17:30 
GeneralRe: Creating the Treeview nodes dynamically Pin
Jodd11-Jan-05 3:01
Jodd11-Jan-05 3:01 
GeneralDataGrid Mouse Hover Pin
Sumit Domyan10-Jan-05 16:19
Sumit Domyan10-Jan-05 16:19 
GeneralRe: DataGrid Mouse Hover Pin
Robert Rohde11-Jan-05 3:03
Robert Rohde11-Jan-05 3:03 
GeneralVB Callback functions in a C DLL Pin
mannywine10-Jan-05 11:04
mannywine10-Jan-05 11:04 
GeneralVB Web Server Pin
RCOLATRU10-Jan-05 11:02
RCOLATRU10-Jan-05 11:02 
GeneralRe: VB Web Server Pin
Dave Kreskowiak11-Jan-05 4:25
mveDave Kreskowiak11-Jan-05 4:25 
GeneralRe: VB Web Server Pin
RCOLATRU11-Jan-05 4:38
RCOLATRU11-Jan-05 4:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.