Click here to Skip to main content
15,903,012 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Open Password protected file Pin
MaheshSelva4-Jul-09 6:30
MaheshSelva4-Jul-09 6:30 
GeneralRe: Open Password protected file [modified] Pin
harold aptroot4-Jul-09 6:45
harold aptroot4-Jul-09 6:45 
GeneralRe: Open Password protected file Pin
Colin Angus Mackay4-Jul-09 6:51
Colin Angus Mackay4-Jul-09 6:51 
Question3D project for VB.Net Pin
phowarso3-Jul-09 20:28
phowarso3-Jul-09 20:28 
AnswerRe: 3D project for VB.Net Pin
K03063-Jul-09 20:34
K03063-Jul-09 20:34 
QuestionI'd like to develop a basic file-sharing app Pin
RogueTrooper3-Jul-09 14:23
RogueTrooper3-Jul-09 14:23 
AnswerRe: I'd like to develop a basic file-sharing app Pin
RogueTrooper3-Jul-09 15:34
RogueTrooper3-Jul-09 15:34 
QuestionTape Drive Help [modified] Pin
keiichicom3-Jul-09 11:52
keiichicom3-Jul-09 11:52 
Hi,

I am using the Fire Streamer tape drive emulator. I have a simulated tape drive and a simulated tape (a file). I can open a handle to the tape drive and determine that it uses variable block size. I can set the block size of the tape properly. I use msgbox to verify that this is working, But when it comes to reading or writing to the tape I get "incorrect function" if I use stream.write or stream.read or if I use the win32api ReadFile and WriteFile appear to work but they always read or write 0 bytes.

Any help would be appreciated. Start with the button4 click method below which calls write...

p.s. I create m_stream when I get a handle to the tape with createfile(not shown) as a synchronous stream.

Here is a section of code: I have bolded some statements.

Private Sub write(ByVal startpos As Long, ByVal lstream As Byte())
        Dim numberofBlocks As System.UInt32
        numberofBlocks = GetBlocksNumber(lstream.Length)
        TapeSeek(startpos)
        Dim arrayToWrite(numberofBlocks * BlockSize() - 1) As Byte
        Array.Copy(lstream, arrayToWrite, lstream.Length)
        m_stream.Write(arrayToWrite, 0, arrayToWrite.Length)
        m_stream.Flush()
        REM  Dim nbr As System.Int32
        REM nbr = 0
        REM retval = WriteFile(m_handleValue, arrayToWrite, 512, nbr, Nothing)
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click        
        Dim selecteddrive As String
        selecteddrive = "\\.\" + ComboBox1.SelectedItem.ToString
        TapeLoad(selecteddrive)
        Dim mediainfo As New DRIVE_INFO
        Dim msize As Integer
        Dim ptr As System.IntPtr
        Dim ptr2 As System.IntPtr
        Dim ptr3 As System.IntPtr
        Dim mediasize2 As New TAPE_MEDIA_INFO
        Dim mediasize As New TAPE_SET_MEDIA_PARAMETERS
        ptr = IntPtr.Zero
        msize = Marshal.SizeOf(mediainfo)
        ptr = Marshal.AllocHGlobal(msize)
        Dim deleteold As Boolean
        deleteold = True
        Marshal.StructureToPtr(mediainfo, ptr, deleteold)
        retval = GetTapeParameters(m_handleValue, GET_TAPE_DRIVE_INFORMATION, msize, ptr)
        Marshal.PtrToStructure(ptr, mediainfo)
        If mediainfo.FeaturesLow And TAPE_DRIVE_VARIABLE_BLOCK Then
            ptr2 = IntPtr.Zero
            msize = Marshal.SizeOf(mediasize)
            ptr2 = Marshal.AllocHGlobal(msize)
            mediasize.BlockSize = mediainfo.MaximumBlockSize
            Marshal.StructureToPtr(mediasize, ptr2, deleteold)
            retval = SetTapeParameters(m_handleValue, SET_TAPE_MEDIA_INFORMATION, ptr2)
            MsgBox("Setting Variable Tape Block Size to Maximum Value of: " + Str(mediainfo.MaximumBlockSize) + " Bytes")
            Marshal.PtrToStructure(ptr2, mediasize)
            Dim myblocksize As System.Int32
            myblocksize = BlockSize()
        End If
        MsgBox("Using Maximum Block Size of: " + Str(mediainfo.MaximumBlockSize) + " Bytes")
        Marshal.FreeHGlobal(ptr)
        Marshal.FreeHGlobal(ptr2)
        Marshal.FreeHGlobal(ptr3)
        Dim mystream(BlockSize() - 1) As Byte
        mystream(1) = 99
        mystream(511) = 99
        write(101, mystream)
        TapeDriveClose()
    End Sub



Thanks, Keiichicom

modified on Tuesday, July 7, 2009 6:05 PM

AnswerRe: Tape Drive Help Pin
Henry Minute4-Jul-09 0:54
Henry Minute4-Jul-09 0:54 
GeneralRe: Tape Drive Help Pin
keiichicom7-Jul-09 12:08
keiichicom7-Jul-09 12:08 
QuestionClient Ip address Pin
ksss_maheshece3-Jul-09 2:00
ksss_maheshece3-Jul-09 2:00 
AnswerRe: Client Ip address Pin
DoctorMick3-Jul-09 2:23
DoctorMick3-Jul-09 2:23 
GeneralRe: Client Ip address Pin
ksss_maheshece3-Jul-09 2:52
ksss_maheshece3-Jul-09 2:52 
GeneralRe: Client Ip address Pin
Not Active3-Jul-09 3:42
mentorNot Active3-Jul-09 3:42 
GeneralRe: Client Ip address Pin
ksss_maheshece3-Jul-09 20:13
ksss_maheshece3-Jul-09 20:13 
Questiondetect LAN cable unplugged Pin
Member 43208313-Jul-09 1:46
Member 43208313-Jul-09 1:46 
AnswerRe: detect LAN cable unplugged Pin
Vasudevan Deepak Kumar3-Jul-09 2:15
Vasudevan Deepak Kumar3-Jul-09 2:15 
GeneralRe: detect LAN cable unplugged Pin
Member 43208315-Jul-09 21:17
Member 43208315-Jul-09 21:17 
Questioncode help in c#.net for burning dvd using imapi Pin
mukulsharma11463-Jul-09 1:30
mukulsharma11463-Jul-09 1:30 
AnswerRe: code help in c#.net for burning dvd using imapi Pin
Tamer Oz3-Jul-09 1:47
Tamer Oz3-Jul-09 1:47 
QuestionStarting Processes Under Current Logged in User Pin
Tristan Rhodes3-Jul-09 0:59
Tristan Rhodes3-Jul-09 0:59 
QuestionDollar value Pin
ksss_maheshece2-Jul-09 23:49
ksss_maheshece2-Jul-09 23:49 
AnswerRe: Dollar value Pin
K03063-Jul-09 0:15
K03063-Jul-09 0:15 
GeneralRe: Dollar value Pin
ksss_maheshece3-Jul-09 0:31
ksss_maheshece3-Jul-09 0:31 
QuestionDatabinding to ToolstripcomboBox in ToolstripDropdown Pin
ShweBo2-Jul-09 18:24
ShweBo2-Jul-09 18:24 

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.