Click here to Skip to main content
15,919,613 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: How to Insert Table in Rich Text Control Pin
jzsmith3321-Feb-04 21:30
jzsmith3321-Feb-04 21:30 
GeneralCompletely Dynamic Menu Pin
Pugman81214-Feb-04 20:34
Pugman81214-Feb-04 20:34 
GeneralRe: Completely Dynamic Menu Pin
Yogendra Agarwal19-Feb-04 9:19
Yogendra Agarwal19-Feb-04 9:19 
GeneralOne form MDI only admitted Pin
Member 87881514-Feb-04 10:37
Member 87881514-Feb-04 10:37 
Generalhide a from which is not foucsed Pin
aynka200014-Feb-04 7:26
aynka200014-Feb-04 7:26 
GeneralRe: hide a from which is not foucsed Pin
zaheer Asif14-Feb-04 9:58
zaheer Asif14-Feb-04 9:58 
GeneralRe: hide a from which is not foucsed Pin
zaheer Asif14-Feb-04 10:00
zaheer Asif14-Feb-04 10:00 
QuestionHow to create a SPARSE file in VB.NET Pin
WESHILL14-Feb-04 7:23
WESHILL14-Feb-04 7:23 
Hi,

I am trying to create a SPARSE file that reflects the size of an original file. for excample, I would like to create a 33gb(Logical) file that is physically only a few bytes.

I am able to create a 0(logical/physical) byte file only with the following code but I can't seem to get the Logical value assigned. Could someone tel me what I'm missing?

Module Module1

Public Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" ( _
ByVal lpFileName As String, _
ByVal dwDesiredAccess As Integer, _
ByVal dwShareMode As Integer, _
ByVal lpSecurityAttributes As Integer, _
ByVal dwCreationDisposition As Integer, _
ByVal dwFlagsAndAttributes As Integer, _
ByVal hTemplateFile As Integer) As Integer

Public Declare Function SetFilePointer Lib "kernel32" Alias "SetFilePointer" ( _
ByVal hFile As Integer, _
ByVal lDistanceToMove As Integer, _
ByVal lpDistanceToMoveHigh As Integer, _
ByVal dwMoveMethod As Integer) As Integer

Public Declare Function SetEndOfFile Lib "kernel32" ( _
ByVal hFile As Integer) As Integer

Public Declare Function CloseHandle Lib "kernel32" ( _
ByVal hObject As Integer) As Integer

Public Declare Function DeviceIoControl Lib "kernel32" ( _
ByVal hDevice As Long, _
ByVal dwIoControlCode As Long, _
|ByVal lpInBuffer As String, _
ByVal nInBufferSize As Long, _
ByVal lpOutBuffer As String, _
ByVal nOutBufferSize As Long, _
ByVal lpBytesReturned As Long, _
ByVal lpOverlapped As String) As Long

End Module

Public Class Form1

Inherits System.Windows.Forms.Form

Const _WIN32_WINNT = 5
Public Const CREATE_ALWAYS = 2
Public Const CREATE_NEW = 1
Public Const OPEN_ALWAYS = 4 'Create if doesn't exist
Public Const OPEN_EXISTING = 3
Public Const TRUNCATE_EXISTING = 5
Public Const FILE_ATTRIBUTE_ARCHIVE = &H20
Public Const FSCTL_SET_SPARSE = &H900C4
Public Const MOVEFILE_REPLACE_EXISTING = &H1
Public Const FILE_ATTRIBUTE_TEMPORARY = &H100
Public Const FILE_BEGIN = 0
Public Const FILE_SHARE_READ = &H1
Public Const FILE_SHARE_WRITE = &H2
Public Const GENERIC_READ = &H80000000
Public Const GENERIC_WRITE = &H40000000


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim h
Dim d
Dim n
Dim dw As Integer
Dim lDist As Integer

h = CreateFile("D:\Wes.log", GENERIC_WRITE + GENERIC_READ, 0, 0, CREATE_ALWAYS, 0, 0)

dw = 0

d = DeviceIoControl(h, FSCTL_SET_SPARSE, n, 0, n, 0, dw, 0)

lDist = 8

MsgBox(h & " " & lDist)

SetFilePointer(h, 0, lDist, FILE_BEGIN)

CloseHandle(h)

End Sub

AnswerRe: How to create a SPARSE file in VB.NET Pin
Dave Kreskowiak14-Feb-04 9:25
mveDave Kreskowiak14-Feb-04 9:25 
GeneralRe: How to create a SPARSE file in VB.NET Pin
WESHILL14-Feb-04 9:41
WESHILL14-Feb-04 9:41 
GeneralRe: How to create a SPARSE file in VB.NET Pin
Dave Kreskowiak16-Feb-04 8:51
mveDave Kreskowiak16-Feb-04 8:51 
GeneralRe: How to create a SPARSE file in VB.NET Pin
WESHILL24-Feb-04 5:54
WESHILL24-Feb-04 5:54 
GeneralRe: How to create a SPARSE file in VB.NET Pin
WESHILL9-Mar-04 2:03
WESHILL9-Mar-04 2:03 
Questionmousehover? Pin
Nadroj14-Feb-04 6:42
Nadroj14-Feb-04 6:42 
AnswerRe: mousehover? Pin
Matthew Hazlett14-Feb-04 7:13
Matthew Hazlett14-Feb-04 7:13 
GeneralRe: mousehover? Pin
Nadroj14-Feb-04 7:21
Nadroj14-Feb-04 7:21 
GeneralRe: mousehover? Pin
Matthew Hazlett14-Feb-04 7:37
Matthew Hazlett14-Feb-04 7:37 
GeneralRe: mousehover? Pin
Nadroj14-Feb-04 7:44
Nadroj14-Feb-04 7:44 
GeneralNew to VB.Net from VB6 Pin
Gaz@UK14-Feb-04 5:33
Gaz@UK14-Feb-04 5:33 
GeneralRe: New to VB.Net from VB6 Pin
Michael P Butler14-Feb-04 6:07
Michael P Butler14-Feb-04 6:07 
GeneralRe: New to VB.Net from VB6 Pin
Gaz@UK14-Feb-04 21:12
Gaz@UK14-Feb-04 21:12 
QuestionVisual Basic 6.0 Skinning?? Pin
erikkloeze14-Feb-04 3:20
erikkloeze14-Feb-04 3:20 
AnswerRe: Visual Basic 6.0 Skinning?? Pin
r i s h a b h s16-Feb-04 19:45
r i s h a b h s16-Feb-04 19:45 
GeneralRe: Visual Basic 6.0 Skinning?? Pin
erikkloeze17-Feb-04 3:22
erikkloeze17-Feb-04 3:22 
GeneralRe: Visual Basic 6.0 Skinning?? Pin
Wilbur J. Pereira18-Feb-04 7:54
Wilbur J. Pereira18-Feb-04 7:54 

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.