|
I've tried it but it dies with the following error.....
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at WS_NTFS.Module1.DeviceIoControl(Int64 hDevice, Int64 dwIoControlCode, String& lpInBuffer, Int64 nInBufferSize, String& lpOutBuffer, Int64 nOutBufferSize, Int64& lpBytesReturned, String& lpOverlapped)
at WS_NTFS.Form1.Button1_Click(Object sender, EventArgs e) in D:\@Projects\WeshillNTFS\NTFS_5_PT2_Src\WS_NTFS\Form1.vb:line 127
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
|
|
|
|
|
Part of the problem is you are passing in strings for your buffers, don't. This is the example your looking for:
Imports System
Imports System.IO
Imports System.Text
Imports System.Runtime.InteropServices
Module Module1
Private Const FILE_ANY_ACCESS = 0
Private Const FILE_READ_ACCESS = 1
Private Const FILE_WRITE_ACCESS = 2
Private Const FILE_DEVICE_FILE_SYSTEM = 9
Private Const GENERIC_READ = &H80000000
Private Const GENERIC_WRITE = &H40000000
Private Const FILE_SHARE_READ = 1
Private Const FILE_SHARE_WRITE = 2
Private Const CREATE_NEW = 1
Private Const CREATE_ALWAYS = 2
Private Const OPEN_EXISTING = 3
Private Const OPEN_ALWAYS = 4
Private Const TRUNCATE_EXISTING = 5
Public Const FSCTL_SET_REPARSE_POINT = &H900A4
Public Const FSCTL_GET_REPARSE_POINT = &H900A8
Public Const FSCTL_DELETE_REPARSE_POINT = &H900AC
Public Const FSCTL_SET_SPARSE = &H900C4
Public Const FSCTL_SET_ZERO_DATA = &H980C8
Private Const INVALID_HANDLE_VALUE = -1
Private Declare Function GetLastError Lib "kernel32" Alias "GetLastError" () As Integer
Private 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
Private Declare Function CloseHandle Lib "kernel32" Alias "CloseHandle" ( _
ByVal handle As Integer) As Integer
Private Declare Function DeviceIoControl Lib "kernel32" ( _
ByVal hDevice As Integer, _
ByVal dwIoControlCode As Integer, _
ByRef lpInBuffer() As Byte, _
ByVal nInBufferSize As Integer, _
ByRef lpOutBuffer() As Byte, _
ByVal nOutBufferSize As Integer, _
ByRef lpBytesReturned As Integer, _
ByVal lpOverlapped As Long) As Integer
Sub Main()
Dim path As String = "D:\MyTest.dat"
Dim hFileHandle As Integer
Dim rc As Integer
Dim iBytesReturned As Integer
Dim inBuffer(512) As Byte
Dim outBuffer(512) As Byte
hFileHandle = CreateFile(path, GENERIC_READ Or GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, 0, CREATE_ALWAYS, 0, 0)
If hFileHandle <> INVALID_HANDLE_VALUE Then
Console.WriteLine("The {0} file has been created, handle is {1}.", path, hFileHandle)
If Not ReportSparseStatus(path) Then
' Change the status to sparse...
rc = DeviceIoControl(hFileHandle, FSCTL_SET_SPARSE, inBuffer, 0, outBuffer, 0, iBytesReturned, 0)
Console.WriteLine("DeviceIOControl returned {0}.", rc)
CloseHandle(hFileHandle)
If rc = 0 Then
rc = GetLastError()
Console.WriteLine("DeviceIOControl failed with Win32Error {0}.", rc)
Else
Console.WriteLine("DeviceIOControl call with FSCTL_SET_SPARSE returned as successful.")
If ReportSparseStatus(path) Then
Dim fs As New FileStream(path, FileMode.Open, FileAccess.ReadWrite)
fs.SetLength(33792000000) ' SetLength takes a 64-bit Integer, so GB lengths are possible.
fs.Seek(fs.Length, SeekOrigin.Begin)
fs.WriteByte(42)
fs.Close()
End If
End If
End If
Else
Console.WriteLine("Unable to create file!")
rc = GetLastError()
Console.WriteLine("CreateFile failed with Win32Error {0}.", rc)
End If
Console.Write("Done...Press <Enter> to quit.")
Console.ReadLine()
End Sub
Private Function ReportSparseStatus(ByVal path As String) As Boolean
Dim fa As FileAttributes
fa = File.GetAttributes(path)
If (fa And FileAttributes.SparseFile) = FileAttributes.SparseFile Then
Console.WriteLine("The {0} file is tagged as a sparse file.", path)
Return True
Else
Console.WriteLine("The {0} file is NOT tagged as a sparse file.", path)
Return False
End If
End Function
End Module
Hope this helps!
BTW: Why would you want to create a 33GB file with nothing in it?
RageInTheMachine9532
|
|
|
|
|
I will give this a try. The reason for this is that I want to copy the original file to tape, for example, then create an empty file of the same name, to free up space. This file will act as a reference to remind me that I do have a file by that name on tape. I know that I could create a 0 byte file but I prefer to see the original size of the file without actually having it use the disk space.
I am hoping that Sparsing would help with this.
Thanks for your help.
|
|
|
|
|
I have tried this and it works beautifully. Thanks so much.
I have another question... I notice when the file is sparsed I have access to that space, however, when I try to copy or delete the Sparsed file the OS treats it like a regular file. For example, instead of coping 8kb of data it tries to copy 33gb. Is there a way to view the logical size as 33gb but tell the OS to treat it as an 8kb file during these type of manipulations?
Thanks,
I am not sure if there is someway besig
|
|
|
|
|
im very new to vs.net windows apps. i know the console apps quite a bit now. i am also coming from vb6.
i was just wondering how to perform code when events such as mousehover occurs? or any of these basic events. any help appreciated, thanks.
------------------------
Jordan.
III
|
|
|
|
|
If you are using the VS.NET IDE then in the code view there are two dropdowns. Set the first dropdown to the object you want to set the event for and set the second dropdown to the event you want to hook into. It will generate the Subs for you, you just fill in the details.
-OR-
If you are not using the IDE then you can use addHandler to hook into the events.
ex. addhandler Panel1.Click, addressof clickResponse
(addrssof sets clickResponse as the callback sub)
the advantage to doing this is you can do somthing like
addhandler Panel1.Click, addressof clickResponse
addhandler Panel2.Click, addressof clickResponse
addhandler Panel3.Click, addressof clickResponse
and in clickResponse just do a sender.name to get the object that called the sub
-or (the easiest way) -
You can declare it like this:
Private Sub Panel1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Panel1.Click
The handles on the end specifies whats tied to this sub
you can also specify multiple events this way like so:
Private Sub Panel1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Panel1.Click, Panel2.Click, Panel3.Click
as you can see the name of the sub is not important using this method it could be anything you want like..
Private Sub eatAtJoes(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Panel1.Click, Panel2.Click, Panel3.Click
|
|
|
|
|
first of all, thank you.
and i do like that last easy method..
only one problem, i was just messing around with the events for a button. im using system.eventargs to handle the click event, and forms.mouseeventargs to handle mousemove. is there a page to go to that gives a list of all the references you must use in order to do each event? like, say i want to do an event for a button which controls the mousedown method. is there a way of determining what you need to set 'e' as?
------------------------
Jordan.
III
|
|
|
|
|
|
about the 'e' thing, i was referring to the 'ByVal e As System.EventArgs' part. i guess i shouldntve said what do you set e to, but what type, or event, or wutever its called, do you set e to. but thank you.
I will go check out the docs now, thx again for ur help.
------------------------
Jordan.
III
|
|
|
|
|
I've recently bought VB.net and I like it!
..however, I'm struggling to understand all the new concepts...like forms e.g in VB6 to load another form you would Load Form1, Form1.show...how does this work in VB.net????
|
|
|
|
|
Simply,
Declare an instance of your form and call the Show method.
Dim myForm As New Form2
myForm.Show()
Michael
But you know when the truth is told,
That you can get what you want or you can just get old,
Your're going to kick off before you even get halfway through.
When will you realise... Vienna waits for you? - "The Stranger," Billy Joel
|
|
|
|
|
Thanks...problem solved...
|
|
|
|
|
I'm using VB 6.0 and I was wondering if you could also skin your programs. So that you don't see just the basic VB skin, but that you can adjust this.. Just like you can do with Windows with for example WindowsBlinds...
And by skinning, I don't mean only changing colors but also textures and shapes etc.
Please help me,
<<<eRiK>>>
|
|
|
|
|
Hi...
skinning....
u have to use an image as a form. I mean an image which incorporates the graphic elements of your application. this image would sit on top of your application and you can easily change the colors etc. by just using images of diff colors. For this to happen, no part of your forms shuld be visible to the users but the image.
rIsHaBh
|
|
|
|
|
Whow, I menth skinning your program, so like in WinAmp, you can change shapes, colors and stuff.. So you start (for example WinAmp) whit a rectangle shape and then, with some skins, you can change the whole interface (different shapes, colors, features...). So that, if you make a normal VB program, it's a rectangle shape, I want to create a diiferent shape for instance...
Ok?? Now how to?? Please tell me!!
eRiK
<<<erik>>>
|
|
|
|
|
hey,
if u wanna make ur life easy just use activeskin v4.3 by softshape or better skincrafter. Both of these are activex controls and are very easy to use. Just download and install them. Or u could use VBskinner it's easier u just have to place the control over your form and voila u get a skinnable application. u can also give it an XP or Win 2003 look and feel if u wish complete with menus and buttons.
;)
|
|
|
|
|
I have been trying to install SQL Server from Windows 2000 disc so that I can be able to use VB.NET front end on SQL SERVER.The Windows XP I am running does not allow any program from earlier version of Windows to be installed. Can anyone give me an idea on how I can acquire an SQL Server that is compatible with VB.NET to sit on my computer?
to all who have given me replies before, thank you, they have always been helpful
Ben
|
|
|
|
|
bensoncd wrote:
I have been trying to install SQL Server from Windows 2000 disc
Huh?
SQL Server isn't distributed as part of Windows 2000 - it's a distinct product, so I'm confused by your statement here.
I run SQL Server 2000 Developer Edition on an XP box at work, and have used ADO.NET in VB.NET to access it without any problems.
I think Visual Studio.NET ships with MSDE (which is the SQL Server engine with some of the enterprise bits removed), which is suitable for most database development work as well. You may not have installed it though.
Ian Darling
"One of the few systems...which has had “no deaths” in the reliability requirements." - Michael Platt
|
|
|
|
|
Thank you Michael , you may have clarified a point. I had got the instruction from the Dummies addition (VB.NET Database Programming for Dummies), to use Windows 2000 disc to install SQL Server 2000. Seemed not to work. So it seems I will have to purchase SQL Server 2000 package hey. The version of Visual Studio I have is the Student version; does not ship with MSDE.
As someone who is still on the learning curve, I would also like to get an opinion on the future of an aspiring VB.NET/SQL Server programmer.
Thank you Mic
|
|
|
|
|
In tab control the are 3 tab page
when i click a button with is in tabpage 1
i have written(tabpage3.focus) the focus to go to tabpage 3 but its not going what can i do pls help
|
|
|
|
|
Are you talking about when you right click on a tab setting it to focused before you "do stuff" to the tabpage. If so I was having this problem the other day and fixed it with a little workaround.
Private Sub tabFromClick(ByVal e As System.Windows.Forms.MouseEventArgs)
Dim thisTab As Integer
For thisTab = 0 To Me.TabCount - 1
Dim tabRect As Rectangle = Me.GetTabRect(thisTab)
If tabRect.Contains(New Point(e.X, e.Y)) Then
Me.SelectedIndex = thisTab
End If
Next
End Sub
|
|
|
|
|
I am able to do Upload a file (or copy it) and name it with a variable (moving from a local local to the website) with the following code in the script editor (Frontpage) using the CopyFile Path fso method:
<script language="vbscript">
Sub Submit_OnClick
Dim Path
Dim TheForm
Dim NewFolder
Set TheForm = Document.UploadForm
NewFolder = TheForm.UserName.Value
Dim fso
Dim PictureName
Set fso = CreateObject("Scripting.FileSystemObject")
PictureName = TheForm.PictureName.Value
If IsNull(UploadForm.PictureName.Value) = False Then
fso.CopyFile Path, "C:\Inetpub\wwwroot\ADI\FileUploads\" & NewFolder & "" & PictureName & ".bmp"
Else
End If
End Sub
</script>
But when I go to preview it in the actual browser I get this message:
A Runtime Error has occurred
Do You Wish to Debug?
Error: ActiveX component can't create object 'Scripting.FileSystemObject'
I've been advised that this is caused by security settings and that most PC's are set up this way
Apparantly fso's infringe on security because you have access to files on the hard drive
I've been to all the windows sites and downloaded MDAC 2.1 or better and the latest scripting engines
from microsoft's website, one person even advised uninstalling and reinstalling Frontpage, which I did to no avail. It seems to be actually quite an apidemic, if you tpye in the above error in google.com you get a slew of results.
Well, I'm wondering if there's a more secure way for users to upload files besides using an FSO
Can anyone help me?
|
|
|
|
|
In client side scripting you can't access the file system
this is very harmfull for internet users
I read about *.hta applications (web pages hosted in browser) that can do this. But I have no more info about them.
|
|
|
|
|
Can anyone tell me how text can re-appear in the text box that was previously entered when the userform is re-opened.
The way my code is written now. When you re-open the userform the text boxes are automatically cleared for new text to be entered.
Please look at this code below:
Private Sub cmdOK Click()
If textbox1.TextLength > 0 Then
ActiveSheet.Cells(5, 2).Value = textbox1.Text
Unload UserForm1
Else
MsgBox "You are required to enter text. Please enter it now.", vbCritical
End If
End Sub
If you have any code examples, please share them with me. Thanks. I would really appreciate the help.
|
|
|
|
|
hmm.. sry to get ur hopes up. u prolly think iv got a solution, which i dont.
i dont know anything about these userforms your talking about. iv worked with vb6 windows apps, but not in vb.net. only console apps. i am prolly way off, but, couldnt u just make a hidden text box or label to store the previous forms' value?
------------------------
Jordan.
III
|
|
|
|
|