|
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
|
|
|
|
|
It is extremely unlikely that anyone will bother to read through that horribly formatted pile.
If you want help, please edit your post, surround the code with <pre>your code</pre> tags, remove anything not directly related to the problem, and format it properly. You know indentation etc. You might be better cutting the code from your editor and pasting it between the tags, that way your existing formatting will be preserved.
Even if you had formatted it properly there is just too much code there for most people to bother reading it.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thanks for your advice, Henry. You are right , it was one big mess to read. I have made the changes and it should be easier to read now. Please help if you can.
Appreciated, Keiichicom
|
|
|
|
|
Hello friends,
can i get client ip address at which my application running.I want capture that address coz of restrict from frauds. This form is very helpful for freshers like me.Thanks in Advance.
With Regards,
MAHESH.K
|
|
|
|
|
Is it a web or windows application?
|
|
|
|
|
|
|
|
Hi I'm trying to develop an application that can detect when a LAN cable is plugged in/unplugged(mind you only LAN cable,should not apply to a Wireless LAN being switched on/off). I did my research and am trying to do it through WMI. The code is as follows but doesn't seem to work. It seems as my event handler isn't handling the events caught by the event watcher.Help!
code:
Imports System.Management
Public Class Form1
Friend WithEvents mew As ManagementEventWatcher
Sub New()
Dim myMS As New ManagementScope("\\.\root\cimv2")
myMS.Connect()
If myMS.IsConnected Then
MsgBox("Connected")
mew = New ManagementEventWatcher("select * from __InstanceModificationEvent within 1 where targetinstance ISA ""Win32_NetworkAdapter""")
mew.Start()
End If
End Sub
Private Sub arrived(ByVal sender As Object, ByVal e As System.Management.EventArrivedEventArgs) Handles mew.EventArrived
Dim mbo, obj As ManagementBaseObject
mbo = CType(e.NewEvent, ManagementBaseObject)
obj = CType(mbo("TargetInstance"), ManagementBaseObject)
MsgBox(obj("Name") + ":" + obj("ConnectionStatus"))
MsgBox(e.Context.ToString)
End Sub
End Class
|
|
|
|
|
|
Well the SensAPI has an IsNetworkAlive function that is supposed to be really slow.Also it checks for network availability. What I want is to be able to detect when a user unplugs a network cable form his tower. The way Windows detects it(although not always accurately) and shows a balloon saying "Network cable unplugged". Is there any event I could use? And the code that I posted works fine when one disables/enables from "dialup and network connections" but not when the cable is manually unplugged. ??? If there is any unmanaged API that I could use, that would be halpful too. Thanks
|
|
|
|
|
Hello frnds.
im developing an application in c#.net for burning a dvd using IMAPI.
can anyone help me with its code !!!
also in my ui for the application..
how can i display the data of the selected path(data to be burned on the dvd) and its size in a listbox or in any other control???
plzzz help....
thanking you in advance...
mukul
|
|
|
|
|
|
Hi Guys,
I'm starting a process from inside an Installer component that should auto start the app just installed. However, the process starts up as a SYSTEM process, rather than the current logged in user. This is causing a number of problems.
I've tried using the ProcessStartInfo.LoadUserProfile as true, and UseShellExecute as false, but this still doesn't seem to change the process starting under the SYSTEM user.
Does anyone else have any ideas?
Ideally, I'd like to avoid having to enter a password. I'd hoped the HKEY_CURRENT_USER setting would have sorted that out ok.
Regards
Tris
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
modified on Friday, July 3, 2009 8:07 AM
|
|
|
|
|
HEllo friends,
i come with a question. Can i get dollar values for my website?if yes then How can i get that factor against Rupees.
Thank in Advance.
|
|
|
|
|
|
thank u kkarthik200
Keep Rocks
|
|
|
|
|
noticed the strange behavior of Databinding to ToolstripComboBox.Combobox when it is being added to ToolstripDropdown or Contextmenu. Normally I'm binding SQL data to ToolstripcomboBox.Combobox by following code.
Me.tspcbxTest.ComboBox.ValueMember = "ID"
Me.tspcbxTest.ComboBox.DisplayMember = "Column_to_Dispaly"
Me.tspcbxTest.ComboBox.FormattingEnabled = True
Me.tspcbxTest.ComboBox.DataSource = Me.Table1BindingSource
Me.Table1TableAdapter.Fill(Me.DataSet1.Table1)
Though it works perfect on ToolstripcomboBox(es) on ToolStrip or MenuStrip, failed on ToolStripSpiltButton (or) ToolStripDropdown (or) Contextmenu.
Thanking in advance.
Please!
|
|
|
|
|
I was just going through your snippet. I just wonder, did not you put something like below to bind.
<> is used as place holders.
this.tspcbxTest.ComboBox.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", <datasource>, "<valuefield>", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
|
|
|
|
|
try this
Me.tspcbxTest.ComboBox.BindingContext = Me.BindingContext
Me.tspcbxTest.ComboBox.ValueMember = "ID"
Me.tspcbxTest.ComboBox.DisplayMember = "Column_to_Dispaly"
Me.tspcbxTest.ComboBox.FormattingEnabled = True
Me.tspcbxTest.ComboBox.DataSource = Me.Table1BindingSource
Me.Table1TableAdapter.Fill(Me.DataSet1.Table1)
|
|
|
|
|
Hi Infarkt!
Much appreciate for your advice.
I didn't notice that I've to assign it's binding context, that wasn't require in WinForms ComboBox.
Finally I solve the problem with following snippet.
Dim cb As ComboBox = DirectCast(tspcbxTest.Control, ComboBox)
With cb
.BindingContext = Me.BindingContext()
.FormattingEnabled = True
.DisplayMember = "Column_to_Dispaly"
.ValueMember = "ID"
'I declared new BindingSource so it doesn't relate to another control(s) with same BindingSource
Dim bs As New BindingSource(Me.Table1BindingSource, "")
.DataSource = bs
bs.Sort = "Column_to_sort_1,Column_to_sort_2,blah,blah"
Me.Table1TableAdapter.Fill(Me.DataSet1.Table1)
bs = Nothing
Thank you.
|
|
|
|
|
Hi Infarkt!
Much appreciate for your advice.
I didn't notice that I've to assign it's binding context, that wasn't require in WinForms ComboBox.
Finally I solve the problem with following snippet.
Dim cb As ComboBox = DirectCast(tspcbxTest.Control, ComboBox)
With cb
.BindingContext = Me.BindingContext()
.FormattingEnabled = True
.DisplayMember = "Column_to_Dispaly"
.ValueMember = "ID"
'I declared new BindingSource so it doesn't relate to another control(s) with same BindingSource
Dim bs As New BindingSource(Me.Table1BindingSource, "")
.DataSource = bs
bs.Sort = "Column_to_sort_1,Column_to_sort_2,blah,blah"
Me.Table1TableAdapter.Fill(Me.DataSet1.Table1)
bs = Nothing
Thank you.
|
|
|
|
|
For a little WinForms application I'm working on, I have a grid of Buttons and I want to be able to press and hold the left mouse button and as the mouse is moved from Button to Button I want the Buttons it crosses to receive mouse events (kinda sorta like in MineSweeper). But I find that the Button I start on captures the mouse.
So far I have written a handler for the MouseCaptureChanged event that will set Capture to false if it has become true and it works pretty well.
private void
DeCapture
(
object sender
,
System.EventArgs e
)
{
System.Windows.Forms.Control temp = sender as System.Windows.Forms.Control ;
if ( ( temp != null ) && ( temp.Capture ) )
{
temp.Capture = false ;
}
return ;
}
However, it seems like I should be able to set the Button so that it won't capture the mouse in the first place; is there a way to do so?
|
|
|
|
|
I do not know of a property or method of button that will allow you to turn mouse capture off. Although obviously now that I have said that someone will come along and tell you about one!
Apart from the method that you are currently using, the only way I can think of is to use faux buttons on a panel or usercontrol with a GetButtonAt(x, y) method and do the drawing of pressed/unpressed state yourself in response to OnMouseMove, OnMouseDown, OnMouseUp etc.
There was (back in the VS2003 days) an MSDN Sample called ButtonArray Sample that did something similar.
There still is! Found it here[^].
Hope this helps.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Great, thanks, I downloaded it and I'll take a look.
|
|
|
|