Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Wednesday, July 1, 2015 6:04 AM
Hi all,
I am working on one project I am using excel in visual studio vb.net development but my excel sheet is in d drive but I want to hide the all supporting sheets in running windows application development.
looking forward for all of yours sugestions
Thanks & Regards
Vinu
Thursday, July 2, 2015 4:11 AM ✅Answered
You can hide a Folder or File if the User logged on does not have the CheckBox in (in Win 7 64 bit) Control Panel, Appearance and Personalization, Folder Options, View, Hidden Files and Folders, Hide protected operating system files (Recommended) unchecked using the 1st code below. Top pic in the image is the app.
If the D drive is a memory stick or thumb drive then you could possibly use the second code below. It destroys the memory sticks format though when it is used. With it you could write all the bytes of the files to the thumbdrive but then your program would have to know where the files bytes begin and end for each file and what the files names are somehow. Which I suppose you could create a byte array of that information and write it to a known location on the D drive. But then when you update any file it would be difficult to alter its bytes since doing so may overwrite bytes of another file already stored on the drive. Very difficult to implement. App is second pic in image below. Note that when this code is used the memory stick, when plugged in, appears not formatted to Windows but you can still access it.
The third code below will encrypt and decrypt a file using TripleDES. You would need to learn about that. And hardcoding the encryption key and vector in your app would make it susceptable to hacking so somebody could figure out how to encrypt and decrypt the files by hacking your app. Third pic in image below.
And then there's this thread How to replace or remove last 500 bytes of a file without rewriting all the file? you can review in which uses RSA Keys for a user and Rijndael encryption/decryption to encrypt and decrypt files in which you can export keys to put on another system via import for a user. No code is at the link and any links to my OneDrive are broken for any apps since I've deleted them out of my OneDrive. I can upload the app again if you would like.
Code for 1st app
Option Strict On
Imports System.IO
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.CenterToScreen()
Me.Text = "Make a Folder super hidden"
RichTextBox1.Text = "Text to write to file in super hidden folder"
End Sub
Dim Path As String = ""
' The below code turns a chosen folder into a super hidden folder. The folder can not be seen by Windows Explorer
' or the command prompts dir command if Control Panel, Appearance and Personalization, Folder Options, View,
' "Show hidden files, folders, and drives" is on (unless the folder is on the desktop for some reason. Then it's
' partially transparent and can be seen on the desktop). It can only be seen if Control Panel, Appearance and Personalization,
' Folder Options, View, "Hide protected operating system files (Recommended)" is unchecked which is uncommon.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim FBD As New FolderBrowserDialog
FBD.Description = "Create Secret Hidden Folder"
FBD.ShowNewFolderButton = True
FBD.SelectedPath = "C:\Users\John\Desktop"
If FBD.ShowDialog = Windows.Forms.DialogResult.OK Then
Path = FBD.SelectedPath
Dim DirInfo As New IO.DirectoryInfo(Path)
DirInfo.Attributes = FileAttributes.System Or FileAttributes.Hidden
End If
FBD.Dispose()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If Path <> "" Then
My.Computer.FileSystem.WriteAllText(Path & "\Testing.Txt", RichTextBox1.Text, False)
End If
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If Path <> "" Then
RichTextBox2.Text = My.Computer.FileSystem.ReadAllText(Path & "\Testing.Txt")
End If
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
My.Computer.FileSystem.DeleteDirectory(Path, FileIO.DeleteDirectoryOption.DeleteAllContents)
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
Dim OFD As New OpenFileDialog
OFD.Title = "Create secret hidden file"
OFD.InitialDirectory = "C:\Users\John\Desktop"
OFD.Filter = "Text files (*.Txt)|*.Txt"
OFD.Multiselect = False
If OFD.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim FileInfo As New IO.FileInfo(OFD.FileName)
FileInfo.Attributes = FileAttributes.System Or FileAttributes.Hidden
End If
OFD.Dispose()
End Sub
End Class
Code for 2nd app
Option Strict On
Imports System.Runtime.InteropServices
Public Class Form1
<DllImport("kernel32", SetLastError:=True)> _
Private Shared Function CreateFile( _
ByVal FileName As String, _
ByVal DesiredAccess As Integer, _
ByVal ShareMode As Integer, _
ByVal SecurityAttributes As IntPtr, _
ByVal CreationDisposition As Integer, _
ByVal FlagsAndAttributes As Integer, _
ByVal hTemplateFile As IntPtr) As IntPtr
End Function
<DllImport("kernel32", SetLastError:=True)> _
Private Shared Function CloseHandle(ByVal hObject As IntPtr) As Boolean
End Function
' Very specific DeviceIOControl...
<DllImport("kernel32.dll", SetLastError:=True)> _
Private Shared Function DeviceIoControl( _
ByVal deviceHandle As IntPtr, _
ByVal controlCode As Int32, _
ByVal inBuffer As IntPtr, _
ByVal inBufferSize As Int32, _
ByRef outBuffer As DiskGeometry, _
ByVal outBufferSize As Int32, _
ByRef bytesReturned As Int32, _
ByVal overlapped1 As IntPtr) As Integer
End Function
<DllImport("kernel32")> _
Private Shared Function SetFilePointerEx( _
ByVal hFile As IntPtr, _
ByVal DistanceToMove As UInt64, _
ByRef NewFilePointer As UInt64, _
ByVal MoveMethod As MoveMethod) As Boolean
End Function
<DllImport("kernel32")> _
Private Shared Function ReadFile( _
ByVal hFile As IntPtr, _
<MarshalAs(UnmanagedType.LPArray, _
ArraySubType:=UnmanagedType.U1, _
SizeParamIndex:=2)> _
ByVal buffer() As Byte, _
ByVal NumberOfBytesToRead As UInteger, _
ByRef lpNumberOfBytesRead As UInteger, _
ByVal overlapped As IntPtr) As Boolean
End Function
<DllImport("kernel32")> _
Private Shared Function WriteFile( _
ByVal hFile As IntPtr, _
ByVal buffer() As Byte, _
ByVal NumberOfBytesToWrite As UInteger, _
ByRef NumberOfBytesWritten As UInteger, _
ByVal overlapped As IntPtr) As Boolean
End Function
<StructLayout(LayoutKind.Sequential)> _
Private Structure DiskGeometry
Public Cylinders As Int64
Public MediaType As MediaType
Public TracksPerCylinder As UInteger
Public SectorsPerTrack As UInteger
Public BytesPerSector As UInteger
End Structure
Private Enum MoveMethod As Integer
FILE_BEGIN
FILE_CURRENT
FILE_END
End Enum
Private Enum MediaType
' There are loads of these, but
' they are mainly archaic floppies.
' It will be this one...
RemovableMedia = 22
End Enum
Private Const genericRead As Integer = &H80000000
Private Const genericWrite As Integer = &H40000000
Private Const fileShareRead As Integer = 1
Private Const fileShareWrite As Integer = 2
Private Const openExisting As Integer = 3
Private Const fileAttributeNormal As Integer = &H80
Private Const ioctl_Disk_Get_Drive_Geometry = &H70000
Dim ReadFromDisk As New List(Of Byte)
Dim WriteToDisk As New List(Of Byte)
Dim DrivesHandles As IntPtr
Dim DrivesGeometry As DiskGeometry
Dim DisksSize As ULong = 0
Dim RectanglesToDraw As New List(Of Rectangle)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Location = New Point(CInt((Screen.PrimaryScreen.WorkingArea.Width / 2) - (Me.Width / 2)), CInt((Screen.PrimaryScreen.WorkingArea.Height / 2) - (Me.Height / 2)))
Panel1.AutoScroll = True
Panel1.HorizontalScroll.Enabled = False
Panel1.VerticalScroll.Enabled = True
Panel1.BackColor = Color.Black
PictureBox1.BackColor = Color.Black
PictureBox2.BackColor = Color.Black
ListBox1.SelectionMode = SelectionMode.One
ListBox1.Items.Add("Waiting")
ListBox2.SelectionMode = SelectionMode.None
ListBox2.Items.Add("Waiting")
ListBox3.SelectionMode = SelectionMode.None
ListBox3.Items.Add("Waiting")
ListBox4.SelectionMode = SelectionMode.None
ListBox4.Items.Add("Waiting")
Button2.Enabled = False
Button4.Enabled = False
Button5.Enabled = False
Label5.Left = NumericUpDown1.Left
With NumericUpDown1
.Minimum = 0
.Maximum = 5
.Increment = 1
.InterceptArrowKeys = True
.AllowDrop = False
.Value = 0
.Enabled = False
End With
Label6.Left = NumericUpDown2.Left
With NumericUpDown2
.Minimum = 0
.Maximum = 5
.Increment = 1
.InterceptArrowKeys = True
.AllowDrop = False
.Value = 0
.Enabled = False
End With
ListBox1.Left = Label1.Left
ListBox2.Left = Label2.Left
ListBox3.Left = Label3.Left
ListBox4.Left = Label4.Left
End Sub
Private Sub Form1_Resize(sender As Object, e As EventArgs) Handles Me.Resize
PictureBox1.Refresh()
PictureBox2.Refresh()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
ListBox1.Items.Clear()
ListBox2.Items.Clear()
ListBox3.Items.Clear()
ListBox4.Items.Clear()
For i = 0 To My.Computer.FileSystem.Drives.Count - 1
If My.Computer.FileSystem.Drives(i).DriveType = IO.DriveType.Removable Then
ListBox1.Items.Add(My.Computer.FileSystem.Drives(i))
ListBox2.Items.Add(My.Computer.FileSystem.Drives(i).DriveType)
Try
ListBox3.Items.Add(My.Computer.FileSystem.Drives(i).DriveFormat)
Catch ex As Exception
ListBox3.Items.Add("Unknown")
End Try
End If
Next
Button2.Enabled = True
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If ListBox1.SelectedIndices.Count > 0 Then
Try
DrivesHandles = CreateFile("//./" & ListBox1.SelectedItem.ToString.Substring(0, 1) & ":", genericRead Or genericWrite, fileShareRead Or fileShareWrite, Nothing, openExisting, fileAttributeNormal, Nothing)
If DrivesHandles.ToInt32 > -1 Then
Dim Returned As Integer = 0
Dim IOControlResult As Integer = DeviceIoControl(DrivesHandles, ioctl_Disk_Get_Drive_Geometry, Nothing, 0, DrivesGeometry, Marshal.SizeOf(DrivesGeometry), Returned, Nothing)
If IOControlResult > 0 Then
DisksSize = CULng(DrivesGeometry.Cylinders * DrivesGeometry.TracksPerCylinder * DrivesGeometry.SectorsPerTrack * DrivesGeometry.BytesPerSector)
Dim Okay As Boolean = SetFilePointerEx(DrivesHandles, CULng(NumericUpDown2.Value * DrivesGeometry.BytesPerSector), Nothing, MoveMethod.FILE_BEGIN)
If Okay = True Then
Dim BytesWritten As UInteger = 0
Dim BlockToWrite(CInt(DrivesGeometry.BytesPerSector - 1)) As Byte
Buffer.BlockCopy(WriteToDisk.ToArray, 0, BlockToWrite, 0, WriteToDisk.Count)
Dim MsgResult = MessageBox.Show("Do you want to destroy this drives" & vbCrLf & ListBox1.SelectedItem.ToString & " format?", "WARNING WARNING", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
If MsgResult = DialogResult.Yes Then
WriteFile(DrivesHandles, BlockToWrite, CUInt(BlockToWrite.Length), BytesWritten, Nothing)
Else
CloseHandle(DrivesHandles)
Exit Sub
End If
End If
End If
End If
CloseHandle(DrivesHandles)
Catch ex As Exception
CloseHandle(DrivesHandles)
End Try
Button1.PerformClick()
Button4.Enabled = True
Button5.Enabled = True
End If
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If Button4.Enabled = False And Button5.Enabled = False Then
Button4.Enabled = True
Button5.Enabled = True
End If
Button3.BackColor = Color.Gray
Button3.Enabled = False
End Sub
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
ListBox4.Items.Clear()
ReadFromDisk.Clear()
WriteToDisk.Clear()
RectanglesToDraw.Clear()
DrivesHandles = CreateFile("//./" & ListBox1.SelectedItem.ToString.Substring(0, 1) & ":", genericRead Or genericWrite, fileShareRead Or fileShareWrite, Nothing, openExisting, fileAttributeNormal, Nothing)
Dim Returned As Integer = 0
Dim IOControlResult As Integer = DeviceIoControl(DrivesHandles, ioctl_Disk_Get_Drive_Geometry, Nothing, 0, DrivesGeometry, Marshal.SizeOf(DrivesGeometry), Returned, Nothing)
CloseHandle(DrivesHandles)
If IOControlResult > 0 Then
ListBox4.Items.Add("Media type is " & DrivesGeometry.MediaType.ToString)
ListBox4.Items.Add("Nr of cylinders is " & DrivesGeometry.Cylinders.ToString)
ListBox4.Items.Add("Nr of tracks per cylinder is " & DrivesGeometry.TracksPerCylinder.ToString)
ListBox4.Items.Add("Nr of sectors per track is " & DrivesGeometry.SectorsPerTrack.ToString)
ListBox4.Items.Add("Nr of bytes per sector is " & DrivesGeometry.BytesPerSector.ToString)
ListBox4.Items.Add("Size is approximately " & (DrivesGeometry.Cylinders * DrivesGeometry.TracksPerCylinder * DrivesGeometry.SectorsPerTrack * DrivesGeometry.BytesPerSector).ToString & " bytes")
NumericUpDown1.Maximum = (DrivesGeometry.Cylinders * DrivesGeometry.TracksPerCylinder * DrivesGeometry.SectorsPerTrack) - 1
NumericUpDown2.Maximum = (DrivesGeometry.Cylinders * DrivesGeometry.TracksPerCylinder * DrivesGeometry.SectorsPerTrack) - 1
NumericUpDown1.Enabled = True
NumericUpDown2.Enabled = True
Label5.Text = "Sector to read from = " & NumericUpDown1.Value.ToString & ". Max is sector nr " & (DrivesGeometry.Cylinders * DrivesGeometry.TracksPerCylinder * DrivesGeometry.SectorsPerTrack - 1).ToString
Label6.Text = "Sector to write to = " & NumericUpDown2.Value.ToString & ". Max is sector nr " & (DrivesGeometry.Cylinders * DrivesGeometry.TracksPerCylinder * DrivesGeometry.SectorsPerTrack - 1).ToString
For i = 0 To DrivesGeometry.BytesPerSector - 1
ReadFromDisk.Add(CByte(0))
WriteToDisk.Add(CByte(0))
Next
PictureBox1.Refresh()
PictureBox2.Refresh()
Dim CountPerLine As Integer = 16
Dim NrWidth As Integer = CInt(Math.Floor(PictureBox1.Width / 16))
Dim NrHeight As Integer = NrWidth
PictureBox1.Height = CInt((DrivesGeometry.BytesPerSector / 16) * NrHeight + 2)
PictureBox2.Height = CInt((DrivesGeometry.BytesPerSector / 16) * NrHeight + 2)
Dim CountIt As Integer = 1
Dim x As Integer = 0
Dim y As Integer = 0
For i = 0 To DrivesGeometry.BytesPerSector - 1
If CountIt = CountPerLine + 1 Then CountIt = 1 : x = 0 : y += NrHeight
RectanglesToDraw.Add(New Rectangle(x, y, NrWidth, NrHeight))
x += NrWidth
CountIt += 1
Next
PaintReadFromDisk = True
PaintWriteToDisk = True
PictureBox1.Refresh()
PictureBox2.Refresh()
Else
ListBox4.Items.Add("Waiting")
NumericUpDown1.Enabled = False
NumericUpDown2.Enabled = False
PaintWriteToDisk = False
PaintReadFromDisk = False
PictureBox1.Refresh()
PictureBox2.Refresh()
End If
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Try
DrivesHandles = CreateFile("//./" & ListBox1.SelectedItem.ToString.Substring(0, 1) & ":", genericRead Or genericWrite, fileShareRead Or fileShareWrite, Nothing, openExisting, fileAttributeNormal, Nothing)
If DrivesHandles.ToInt32 > -1 Then
Dim Returned As Integer = 0
Dim IOControlResult As Integer = DeviceIoControl(DrivesHandles, ioctl_Disk_Get_Drive_Geometry, Nothing, 0, DrivesGeometry, Marshal.SizeOf(DrivesGeometry), Returned, Nothing)
If IOControlResult > 0 Then
DisksSize = CULng(DrivesGeometry.Cylinders * DrivesGeometry.TracksPerCylinder * DrivesGeometry.SectorsPerTrack * DrivesGeometry.BytesPerSector)
Dim Okay As Boolean = SetFilePointerEx(DrivesHandles, CULng(NumericUpDown1.Value * DrivesGeometry.BytesPerSector), Nothing, MoveMethod.FILE_BEGIN)
If Okay = True Then
Dim BlockRead(CInt(DrivesGeometry.BytesPerSector - 1)) As Byte
Dim BytesReadIn As UInteger = 0
Dim AOkay As Boolean = ReadFile(DrivesHandles, BlockRead, DrivesGeometry.BytesPerSector, BytesReadIn, Nothing)
If AOkay = True Then
ReadFromDisk.Clear()
For i As Integer = 0 To BlockRead.Length - 1
ReadFromDisk.Add(BlockRead(i))
Next
PictureBox1.Refresh()
End If
End If
End If
End If
CloseHandle(DrivesHandles)
Catch ex As Exception
CloseHandle(DrivesHandles)
End Try
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
Try
DrivesHandles = CreateFile("//./" & ListBox1.SelectedItem.ToString.Substring(0, 1) & ":", genericRead Or genericWrite, fileShareRead Or fileShareWrite, Nothing, openExisting, fileAttributeNormal, Nothing)
If DrivesHandles.ToInt32 > -1 Then
Dim Returned As Integer = 0
Dim IOControlResult As Integer = DeviceIoControl(DrivesHandles, ioctl_Disk_Get_Drive_Geometry, Nothing, 0, DrivesGeometry, Marshal.SizeOf(DrivesGeometry), Returned, Nothing)
If IOControlResult > 0 Then
DisksSize = CULng(DrivesGeometry.Cylinders * DrivesGeometry.TracksPerCylinder * DrivesGeometry.SectorsPerTrack * DrivesGeometry.BytesPerSector)
Dim Okay As Boolean = SetFilePointerEx(DrivesHandles, CULng(NumericUpDown2.Value * DrivesGeometry.BytesPerSector), Nothing, MoveMethod.FILE_BEGIN)
If Okay = True Then
Dim BytesWritten As UInteger = 0
Dim BlockToWrite(CInt(DrivesGeometry.BytesPerSector - 1)) As Byte
Buffer.BlockCopy(WriteToDisk.ToArray, 0, BlockToWrite, 0, WriteToDisk.Count)
WriteFile(DrivesHandles, BlockToWrite, CUInt(BlockToWrite.Length), BytesWritten, Nothing)
End If
End If
End If
CloseHandle(DrivesHandles)
Catch ex As Exception
CloseHandle(DrivesHandles)
End Try
End Sub
Private Sub NumericUpDown1_ValueChanged(sender As Object, e As EventArgs) Handles NumericUpDown1.ValueChanged
Label5.Text = "Sector to read from = " & (NumericUpDown1.Value / NumericUpDown1.Increment).ToString & ". Max is sector nr " & (DrivesGeometry.Cylinders * DrivesGeometry.TracksPerCylinder * DrivesGeometry.SectorsPerTrack - 1).ToString
End Sub
Private Sub NumericUpDown2_ValueChanged(sender As Object, e As EventArgs) Handles NumericUpDown2.ValueChanged
Label6.Text = "Sector to write to = " & (NumericUpDown2.Value / NumericUpDown2.Increment).ToString & ". Max is sector nr " & (DrivesGeometry.Cylinders * DrivesGeometry.TracksPerCylinder * DrivesGeometry.SectorsPerTrack - 1).ToString
End Sub
Dim PaintReadFromDisk As Boolean = False
Private Sub PictureBox1_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox1.Paint
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
e.Graphics.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
If PaintReadFromDisk = True Then
For i = 0 To RectanglesToDraw.Count - 1
e.Graphics.FillRectangle(Brushes.White, RectanglesToDraw(i))
e.Graphics.DrawRectangle(Pens.Black, RectanglesToDraw(i))
Dim StrWidth As Integer = CInt(e.Graphics.MeasureString(ReadFromDisk(i).ToString, New Font("Book Antiqua", 11, FontStyle.Bold)).Width)
Dim StrHeight As Integer = CInt(e.Graphics.MeasureString(ReadFromDisk(i).ToString, New Font("Book Antiqua", 11, FontStyle.Bold)).Height)
e.Graphics.DrawString(ReadFromDisk(i).ToString, New Font("Book Antiqua", 11, FontStyle.Bold), Brushes.Black, CInt(RectanglesToDraw(i).X + (RectanglesToDraw(i).Width / 2) - (StrWidth / 2)), CInt(RectanglesToDraw(i).Y + (RectanglesToDraw(i).Height / 2) - (StrHeight / 2)))
Next
End If
End Sub
Dim PaintWriteToDisk As Boolean = False
Private Sub PictureBox2_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox2.Paint
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
e.Graphics.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
If PaintWriteToDisk = True Then
For i = 0 To RectanglesToDraw.Count - 1
e.Graphics.FillRectangle(Brushes.White, RectanglesToDraw(i))
e.Graphics.DrawRectangle(Pens.Black, RectanglesToDraw(i))
Dim StrWidth As Integer = CInt(e.Graphics.MeasureString(WriteToDisk(i).ToString, New Font("Book Antiqua", 11, FontStyle.Bold)).Width)
Dim StrHeight As Integer = CInt(e.Graphics.MeasureString(WriteToDisk(i).ToString, New Font("Book Antiqua", 11, FontStyle.Bold)).Height)
e.Graphics.DrawString(WriteToDisk(i).ToString, New Font("Book Antiqua", 11, FontStyle.Bold), Brushes.Black, CInt(RectanglesToDraw(i).X + (RectanglesToDraw(i).Width / 2) - (StrWidth / 2)), CInt(RectanglesToDraw(i).Y + (RectanglesToDraw(i).Height / 2) - (StrHeight / 2)))
Next
End If
End Sub
Private Sub PictureBox2_MouseDown(sender As Object, e As MouseEventArgs) Handles PictureBox2.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
For i = 0 To RectanglesToDraw.Count - 1
If RectanglesToDraw(i).Contains(e.X, e.Y) Then
WriteToDisk(i) = CByte(NumberInt)
PictureBox2.Refresh()
End If
Next
ElseIf e.Button = Windows.Forms.MouseButtons.Right Then
NumberStr = ""
Label8.Text = "Replace" & vbCrLf & "byte with" & vbCrLf & NumberStr
End If
End Sub
Private Sub PictureBox2_MouseMove(sender As Object, e As MouseEventArgs) Handles PictureBox2.MouseMove
For i = 0 To RectanglesToDraw.Count - 1
If RectanglesToDraw(i).Contains(e.X, e.Y) Then
Label7.Text = "Byte number = " & (i + 1).ToString
End If
Next
End Sub
Dim NumberInt As Integer = 0
Dim NumberStr As String = ""
Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
If IsNumeric(ChrW(msg.WParam.ToInt32).ToString) Then
Select Case CInt(ChrW(msg.WParam.ToInt32).ToString)
Case 0
If NumberStr <> "0" Then
NumberStr &= ChrW(msg.WParam.ToInt32)
Else
NumberStr = "0"
End If
Case Is > 0
If NumberStr.Count < 3 Then
If CInt(NumberStr & ChrW(msg.WParam.ToInt32)) < 256 Then
NumberStr &= ChrW(msg.WParam.ToInt32)
End If
End If
End Select
If NumberStr <> "" Then
NumberInt = CInt(NumberStr)
Label8.Text = "Replace" & vbCrLf & "byte with" & vbCrLf & NumberStr
Else
Label8.Text = "Replace" & vbCrLf & "byte with" & vbCrLf & NumberStr
End If
End If
Return Nothing
End Function
End Class
Code for 3rd app
Option Strict On
Imports System
Imports System.IO
Imports System.Security.Cryptography
Imports System.Text
Imports System.Runtime.Serialization.Formatters.Binary
'http://msdn.microsoft.com/en-us/library/system.security.cryptography.tripledescryptoserviceprovider.aspx
Public Class Form1
Dim FileNameEncrypt As String = "C:\Users\John\Desktop\Object.Bmp"
Dim FileNameEncrypted As String = "C:\Users\John\Desktop\Object1.Bmp"
Dim FileNameDecrypt As String = "C:\Users\John\Desktop\Object2.Bmp"
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Label4.Text = FileNameEncrypt
Label5.Text = FileNameEncrypted
Label6.Text = FileNameDecrypt
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim EncryptElement As New TripleDESCryptoServiceProvider
EncryptElement.Key = {AscW("B"c), AscW("A"c), AscW("1"c), AscW("R"c), AscW("3"c), AscW("9"c), AscW("G"c), AscW("V"c), AscW("5"c), AscW("S"c), AscW("P"c), AscW("0"c), AscW("L"c), AscW("Z"c), AscW("4"c), AscW("M"c)} '128 bit Key
EncryptElement.IV = {AscW("N"c), AscW("B"c), AscW("5"c), AscW("3"c), AscW("G"c), AscW("L"c), AscW("2"c), AscW("Q"c)} ' 64 bit Initialization Vector
Dim ReadFromFile As FileStream = File.Open(FileNameEncrypt, FileMode.Open, FileAccess.Read)
Dim fStream As FileStream = File.Open(FileNameEncrypted, FileMode.OpenOrCreate)
Dim cStream As New CryptoStream(fStream, New TripleDESCryptoServiceProvider().CreateEncryptor(EncryptElement.Key, EncryptElement.IV), CryptoStreamMode.Write)
Dim Bin(4096) As Byte 'This is intermediate storage for the encryption.
Dim totlen As Long = ReadFromFile.Length 'Total length of the input file.
Dim WriteBytes As Long = 0 'This is the amount of bytes that have been read from the input file.
Dim length As Integer = 0 'This is the number of bytes to be written at a time by cStream.
'Read from the input file, then encrypt and write to the output file.
While WriteBytes < totlen
length = ReadFromFile.Read(Bin, 0, 4096)
cStream.Write(Bin, 0, length)
WriteBytes = Convert.ToInt32(WriteBytes + length)
End While
cStream.Close()
fStream.Close()
ReadFromFile.Close()
Me.Text = "File encryption done"
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim DecryptElement As New TripleDESCryptoServiceProvider
DecryptElement.Key = {AscW("B"c), AscW("A"c), AscW("1"c), AscW("R"c), AscW("3"c), AscW("9"c), AscW("G"c), AscW("V"c), AscW("5"c), AscW("S"c), AscW("P"c), AscW("0"c), AscW("L"c), AscW("Z"c), AscW("4"c), AscW("M"c)}
DecryptElement.IV = {AscW("N"c), AscW("B"c), AscW("5"c), AscW("3"c), AscW("G"c), AscW("L"c), AscW("2"c), AscW("Q"c)}
Dim WriteToFile As FileStream = File.Open(FileNameDecrypt, FileMode.OpenOrCreate) ' FileNameDecrypt is a string representing the Path\Filename you want to give the decrypted file
Dim fStream As FileStream = File.Open(FileNameEncrypted, FileMode.Open, FileAccess.Read) ' FileNameEncrypted is a string representing the Path\Filename of the file you want to decrypt.
Dim cStream As New CryptoStream(fStream, New TripleDESCryptoServiceProvider().CreateDecryptor(DecryptElement.Key, DecryptElement.IV), CryptoStreamMode.Read)
Dim Bin(4096) As Byte
Dim totlen As Long = fStream.Length
Dim ReadBytes As Long = 0
Dim length As Integer = 0
While ReadBytes < totlen - 8
length = cStream.Read(Bin, 0, 4096)
WriteToFile.Write(Bin, 0, length)
ReadBytes = Convert.ToInt32(ReadBytes + length)
End While
fStream.Close()
WriteToFile.Close()
Me.Text = "File decryption done"
End Sub
End Class
Image
La vida loca
Thursday, July 2, 2015 5:22 AM ✅Answered
I uploaded the RSAProgram app to my onedrive. You can download it from the below link. It has a help button that you should select to see how it works if you download it.
La vida loca
Wednesday, July 1, 2015 6:38 AM
Hi,
I'm sorry I can hardly understand your question. Don't you mix up "File(WorkBook)" and "Sheet(WorkSheet)", and is there any relations between your issue and "my excel sheet is in d drive".
If you want to hide all worksheets in an opened workbook(Excel file), it would be easy.
Would you make your question clearer?
Regards,
Wednesday, July 1, 2015 6:43 AM
Hi ,
Thanks for your reply,
I am doing one windows application for my work, In that I am linked excel sheet from my drive D.In the time building MSI/EXE is there any option to hide the excel file permanently from the drive but it should not effect my application process.
Thanks
Vinu
Wednesday, July 1, 2015 7:19 AM
Hi,
I'm sorry I cannot understand your words. Please use correct words, I mean, not gramatically, but technically. Please take a moment to describe your problem.
Regards,
Wednesday, July 1, 2015 7:46 AM
I mean I want hide/encrypt the excel file from the destination through vb.net
Wednesday, July 1, 2015 7:53 AM
Hi,
Do you know to "hide" and to "encrypt" are completely different from each other? And what is "the destination"?
Good-bye
Wednesday, July 1, 2015 8:39 AM
DESTINATION IS D DRIVE
Thursday, July 2, 2015 3:05 AM
Hi,
Thank you for posting in MSDN forum.
Since the issue is related to the vb.net, so we will move this issue to the vb.net forum, you will get better support.
Best Regards,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.