
element
Avatar/Signature-
Posts
28 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by element
-
Hey all, OK I've figured out extracting an icon from Shell32 using the ExtractIcon API like this: <DllImport("shell32.dll", CallingConvention:=CallingConvention.Cdecl)> _ Private Shared Function ExtractIcon _ (ByVal hIcon As IntPtr, _ ByVal lpszExeFileName As String, _ ByVal nIconIndex As Integer) As IntPtr End Function Private m_Icon as Icon Private Sub GetIcon() hIcon = ExtractIcon(IntPtr.Zero, "shell32.dll", 4) m_Icon = Icon.FromHandle(hIcon).Clone DestroyIcon(hIcon) End Sub Private Sub picIcon_Paint(ByVal sender As Object, _ ByVal e As System.Windows.Forms.PaintEventArgs) Handles picIcon.Paint e.Graphics.DrawIcon(m_Icon, 0, 0) End Sub OK this isn't my exact code however it demonstates what is going on. I would like to know how to extract the 48x48 (with alpha) icon from Shell32.dll. ExtractIcon doesn't seem to have any parameters for what format icon you need. ExtractIconEx is no better. Thanks in advance for any input, Tom
-
GetIfTable Pointers in VB.NET
element replied to element's topic in Interoperation / Office Integration
Alright I've figured it all out, in fact, I did so like 2 hours after my original post. I'll paste in the code for a class I have written. Imports System.Runtime.InteropServices Class clsNetworkStats #Region " DECLARES " Private Const MAX_INTERFACE_NAME_LEN As Long = 256 Private Const ERROR_SUCCESS As Long = 0 Private Const MAXLEN_IFDESCR As Long = 256 Private Const MAXLEN_PHYSADDR As Long = 8 <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> Private Structure MIB_IFROW <MarshalAs(UnmanagedType.ByValTStr, sizeconst:=MAX_INTERFACE_NAME_LEN)> Public wszName As String Public dwIndex As UInt32 Public dwType As UInt32 Public dwMtu As UInt32 Public dwSpeed As UInt32 Public dwPhysAddrLen As UInt32 <MarshalAs(UnmanagedType.ByValArray, sizeconst:=MAXLEN_PHYSADDR)> Public bPhysAddr() As Byte Public dwAdminStatus As UInt32 Public dwOperStatus As UInt32 Public dwLastChange As UInt32 Public dwInOctets As UInt32 Public dwInUcastPkts As UInt32 Public dwInNUcastPkts As UInt32 Public dwInDiscards As UInt32 Public dwInErrors As UInt32 Public dwInUnknownProtos As UInt32 Public dwOutOctets As UInt32 Public dwOutUcastPkts As UInt32 Public dwOutNUcastPkts As UInt32 Public dwOutDiscards As UInt32 Public dwOutErrors As UInt32 Public dwOutQLen As UInt32 Public dwDescrLen As UInt32 <MarshalAs(UnmanagedType.ByValArray, sizeconst:=MAXLEN_IFDESCR)> Public bDescr() As Byte End Structure Public Structure IFROW_HELPER Public Name As String Public Index As Integer Public Type As Integer Public Mtu As Integer Public Speed As Integer Public PhysAddrLen As Integer Public PhysAddr As String Public AdminStatus As Integer Public OperStatus As Integer Public LastChange As Integer Public InOctets As Integer Public InUcastPkts As Integer Public InNUcastPkts As Integer Public InDiscards As Integer Public InErrors As Integer Public InUnknownProtos As Integer Public OutOctets As Integer Public OutUcastPkts As Integer Public OutNUcastPkts As Integer Public OutDiscards As Integer Public OutErrors As Integer Public OutQLen As Integer Public Description As String Public InMegs As String Public OutMegs As String End Structure <DllImport("iphlpapi")> Private Shared Function GetIfTable(ByRef pIfRowTable As Byte, ByRef pdwSize As Int32, ByVal bOrder As Int32) As Int32 End Function <DllImport("iphlpapi")> Private Shared Function GetIfEntry(ByRef pIfRow As MIB_IFROW) As Int32 End Function #End Region Private m_Adapters As ArrayList Public Sub New(Optional ByVal IgnoreLoopBack As Boolean = True) Dim lRetSize As Int32, lRows As Int32, ret As Long, i As Byte Dim ifrow As New MIB_IFROW Dim buff(0) As Byte '--//////////////////////////////////////////////////////////////////////////////////////////// ret = GetIfTable(0&, lRetSize, 0) ret = GetIfTable(buff(0), lRetSize, 0) lRows = buff(0) m_Adapters = New ArrayList(lRows) For i = 1 To lRows ifrow = New MIB_IFROW ifrow.dwIndex = Convert.ToUInt32(i) ret = GetIfEntry(ifrow) Dim ifhelp As IFROW_HELPER = PrivToPub(ifrow) If IgnoreLoopBack = True Then If ifhelp.Description.IndexOf("Loopback") < 0 Then m_Adapters.Add(ifhelp) End If Else m_Adapters.Add(ifhelp) End If Next '--//////////////////////////////////////////////////////////////////////////////////////////// End Sub Public Function GetAdapter(ByVal index As Integer) As IFROW_HELPER Return m_Adapters(index) End Function <DebuggerStepThrough()> Private Function PrivToPub(ByVal pri As MIB_IFROW) As IFROW_HELPER Dim ifhelp As New IFROW_HELPER ifhelp.Name = pri.wszName.Trim ifhelp.Index = Convert.ToInt32(pri.dwIndex) ifhelp.Type = Convert.ToInt32(pri.dwType) ifhelp.Mtu = Convert.ToInt32(pri.dwMtu) ifhelp.Speed = Convert.ToInt32(pri.dwSpeed) ifhelp.PhysAddrLen = Convert.ToInt32(pri.dwPhysAddrLen) ifhelp.PhysAddr = System.Text.Encoding.ASCII.GetString(pri.bPhysAddr) ifhelp.AdminStatus = Convert.ToInt32(pri.dwAdminStatus) ifhelp.OperStatus = Convert.ToInt32(pri.dwOperStatus) ifhelp.LastChange = Convert.ToInt32(pri.dwLastChange) ifhelp.InOctets = Convert.ToInt32(pri.dwInOctets) ifhelp.InUcastPkts = Convert.ToInt32(pri.dwInUcastPkts) ifhelp.InNUcastPkts = Convert.ToInt32(pri.dwInNUcastPkts) ifhelp.InDiscards = Convert.ToInt32(pri.dwInDiscards) ifhelp.InErrors = Convert.ToInt32(pri.dwInErrors) ifhelp.InUnknownProtos = Convert.ToInt32(pri.dwInUnknownProtos) ifhelp.OutOctets = Convert.ToInt32(pri.dwOutOctets) ifhelp.OutUcastPkts = Convert.ToInt32(pri.dwOutUcastPkts) ifhelp.OutNUcastPkts = Convert.ToInt32(pri.dwOutNUcastPkts) ifhelp.OutDiscards = Convert.ToInt32(pri.dwOutDiscards) ifhelp.OutErrors = Convert.ToInt32(pri.dwOutErrors) ifhelp.OutQLen = Convert.ToInt32(pri.dwOutQLen) ifhelp.Description = System.Text.Encoding.ASCII.GetString(pri.bDescr, 0, Convert.ToInt32(pri.dwDescrLen)) ifhelp.InMegs = ToMegs(ifhelp.InOctets) ifhelp.OutMegs = ToMegs(ifhelp.OutOctets) Return ifhelp End Function <DebuggerStepThrough()> Private Function ToMegs(ByVal lSize As Long) As String Dim sDenominator As String = " B" 'If lSize > 1024 Then lSize = (lSize / 1024) * 1000 'Windows styleee filesizing :) If lSize > 1000 Then sDenominator = " KB" lSize = lSize / 1000 ElseIf lSize <= 1000 Then sDenominator = " B" lSize = lSize End If ToMegs = Format(lSize, "###,###0") & sDenominator End Function End Class -
Hi, I've been attempting to get this to work for around 5 hours now, getting a little tired of it failing me :S Please can somebody tell me where I'm going wrong, actually - I know where I'm going wrong but I don't know how to fix it. <StructLayout(LayoutKind.Sequential)> Public Class MIB_IFTABLE Public dwNumEntries As Integer <MarshalAs(UnmanagedType.SafeArray)> Public table() As MIB_IFROW End Class <StructLayout(LayoutKind.Sequential)> Public Class MIB_IFROW <VBFixedArray(511)> Public wszName() As Byte '511 'Public wszName As Byte() Public dwIndex As Int32 Public dwType As Int32 Public dwMtu As Int32 Public dwSpeed As Int32 Public dwPhysAddrLen As Int32 <VBFixedArray(7)> Public bPhysAddr() As Byte '7 'Public bPhysAddr() As Byte Public dwAdminStatus As Int32 Public dwOperStatus As Int32 Public dwLastChange As Int32 Public dwInOctets As Int32 Public dwInUcastPkts As Int32 Public dwInNUcastPkts As Int32 Public dwInDiscards As Int32 Public dwInErrors As Int32 Public dwInUnknownProtos As Int32 Public dwOutOctets As Int32 Public dwOutUcastPkts As Int32 Public dwOutNUcastPkts As Int32 Public dwOutDiscards As Int32 Public dwOutErrors As Int32 Public dwOutQLen As Int32 Public dwDescrLen As Int32 <VBFixedArray(255)> Public bDescr() As Byte '255 'Public bDescr() As Byte End Class Above are the classes used. I cannot use Structures for some reason, it says: Additional information: Can not marshal field table of type MIB_IFTABLE: This type can not be marshaled as a structure field. (Note this only happens when I un-comment out the table variable in the MIB_IFTABLE structure) This is the error I get with the code I use below: An unhandled exception of type 'System.Runtime.InteropServices.SafeArrayTypeMismatchException' occurred in mscorlib.dll Additional information: Mismatch has occurred between the runtime type of the array and the sub type recorded in the metadata. Dim lRetSize As Int32, lRows As Int32, ret As Long Dim IfRowTable As New MIB_IFTABLE Dim pStruct As IntPtr = IntPtr.Zero ret = GetIfTable(pStruct, lRetSize, 0) pStruct = Marshal.AllocHGlobal(lRetSize) ret = GetIfTable(pStruct, lRetSize, 0) IfRowTable = Marshal.PtrToStructure(pStruct, GetType(MIB_IFTABLE)) Marshal.FreeHGlobal(pStruct) It is strange, because when I comment out the table variable, it gives me the value of 1311096 in dwNumEntries. This value *should* be two (2 network devices, loopback + NIC) Thank you for any help/advice in advance, Tom
-
Treeview + Imagelist not working! Images not showing at all!
element replied to element's topic in Windows Forms
Hi, Thank you for replying, however this was not the fix I needed, however, a nice control all the same! After hours of hunting, I found it was due to Application.EnableVisualStyles, and this fix was posted on another forum... Here is the link in case anyone else finds this useful: http://windowsforms.net/Forums/ShowPost.aspx?tabIndex=1&tabId=41&PostID=604 Thanks, Tom -
Treeview + Imagelist not working! Images not showing at all!
element posted a topic in Windows Forms
As the title suggests, none of my images are showing in the Treeview control. I have tried a number of ways to get it to work, but have had no success including new treeview and imagelist controls etc. I found this, http://www.dotnet247.com/247reference/msgs/31/155607.aspx which says there might be a problem with Common Controls, although the answer posted is somewhat useless. Any suggestions? Thanks, Tom -
wildfire1982, Thank you for your response! I have investigated the winpcap library (http://winpcap.polito.it/docs/default.htm) and it looks interesting. It certainly appears to be able to provide some network statistics, which is great! When I figure out how to use it (it's all in C++ :S), and what it can really do, I shall post some examples/classes here so everyone can do it! Thanks again, Tom
-
Hello, Is there any way to retrieve network statistics like the total bytes transferred during a network session on a NIC adapter? I've had a look in the Performance Counters under Network Interface but there is only bytes/sec counters. Any help is appreciated, Thanks, Tom
-
Me again, I have an AVI with a media subtype of: {33564944-0000-0010-8000-00AA00389B71} How does GraphEdit know this is DIV3 encoded? I'm using QuartzTypeLib... Thanks, Tom
-
QuartzTypeLib Filter Pin Properties + GraphEdit
element replied to element's topic in Graphics and Multimedia
anybody? anybody know anything about compression decoders and filters? -
OK, tough one: I am in some ways responding to my own question I posted a few days ago... But with no reply... This code returns the Filters and related Pins from a rendered AVI file Graph (like using GraphEdit). 'Don't forget to register Interop.QuartzTypeLib.dll Dim s As String Dim fileManager As New QuartzTypeLib.FilgraphManagerClass Dim filterInfo As QuartzTypeLib.IFilterInfo Dim pin As QuartzTypeLib.IPinInfo Dim iM As QuartzTypeLib.IMediaTypeInfo fileManager.RenderFile("C:\Documents and Settings\My Full Name!\My Documents\test.avi") For Each filterInfo In fileManager.FilterCollection s += "Filter Name: " & filterInfo.Name & vbNewLine For Each pin In filterInfo.Pins s += vbTab & pin.Name & vbNewLine If pin.Name.StartsWith("Stream 00") = True Then iM = pin.ConnectionMediaType() 'Now what? End If Next Next MsgBox(s) So you see it just lists filters and pins. Now GraphEdit allows you to right click on a single Pin off the AVI Splitter (I want pin "Stream 00") and view it's properties. It shows a GUID which correctly corresponds to the iM.Subtype Property, and then gives info on it's FOURCC and decompressor codec (which is DIV3). My question (finally) is how do I get that info? I can email/upload screenshots if it may help. Thank you for any help, Tom
-
Hello, I cannot seem to be able to find a single piece of useful or relevent information on this subject, it must be one of those ones you need to buy a book on :S Anyway, I am looking to retreive information about an AVI file, like it's codec used, and length, framerate, audio channels etc... GSpot (http://www.headbands.com/gspot/) does this very well, and I would like to know how it does it. It appears to have it's own list of FOURCC codes to reference against. However it also gets the codec that is capable of playing the file. Thanks in advance for any information you can provide, Tom P.S. I am using VB.NET 2003
-
I don't honestly know anything about SQL server. All I know is, I install it and it "serves" databases that I can connect to. Great! When distrubuting my program, do they need SQL server to use the database too?
-
yes I agree that adding COM to my project is a bit erm, crap, as the .NET framework provides everything I need. Is there a way to assign a dataset to a dataadapter or will I need to generate the new database using SQL?
-
Hi, Thank you for both of your responses. I have experimented with XML and while excellent for < 1000 records, when dealing with 100,000 records it is glacially slow, and the file sizes/memory usage is enormous! Anyway it seems ADOX is the way to go so I shall be investigating that further. Thank you very much for both your contributions, Tom
-
Seriously, I just don't get it! I have looked on the net, tutorials, bought ADO.NET books, and obviously run thousands of tests, and I am just completly lost. Here is my situation... I am writing a program that basically lists files from cds, for reference. I don't want to use special db servers, dataconnection from a webserver or anything that will involve someone else having to set up a database "connection" to serve from their PC, as I quite honestly don't understand it. I have used DAO before, and it's a doddle, choose your MDB and use it with objects. Also, .NET DataSets are a Godsend as they simply represent the data as it should be. I want the user to basically use Access databases like DAO, so they can choose a file, and with that file they can do anything. Note, files do not require server connections to work! I started using XML but it is WAY to slow to use it for this purpose. If one cd contains about 7000 files, then it is just too much for it. I have created a successful XSD template, and created a DataSet from it, which can be used thoughout the project. I also have one bound control, a ComboBox. My question is this - how can I save the contents of the DataSet to an MDB? The DataAdapter won't do this! I cannot seem to find a way of creating a database FROM an existing DataSet. And once I have created it, I need to be able to open it and use the .Fill to get the data from it, manipulate it, and re-save it all again, or what? I know I am confusing myself here a bit, I was just wondering if someone could shed a little light on the subject. Oh, and did I mention I just wanted to use files? Thanks, Tom
-
GetDriveType() API Errors!
element replied to element's topic in Interoperation / Office Integration
Perfect, now it works like a dream :D Cheers, Tom -
I must admit this is the wierdest problem I have encountered with API and VB.NET... Here's my simple debug code that I used to do some testing after my app was failing: -- API -- Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long Const DRIVE_CDROM = 5 Const DRIVE_FIXED = 3 Const DRIVE_NO_ROOT = 1 Const DRIVE_REMOTE = 4 Const DRIVE_REMOVABLE = 2 And this is the actual code: Debug.WriteLine("A:\ = " & GetDriveType("A:\")) Debug.WriteLine("C:\ = " & GetDriveType("C:\")) Debug.WriteLine("D:\ = " & GetDriveType("D:\")) 'cd Debug.WriteLine("E:\ = " & GetDriveType("E:\")) Debug.WriteLine("F:\ = " & GetDriveType("F:\")) Debug.WriteLine("G:\ = " & GetDriveType("G:\")) Debug.WriteLine("H:\ = " & GetDriveType("H:\")) 'cd Debug.WriteLine("I:\ = " & GetDriveType("I:\")) Both D and H are CD-ROM drives, as funnily enough I need to be able to filter out cd-rom drives from other drives. A:\ is a floppy, and the rest are hard drives. These are my test results: A:\ = 9222812402616107010 C:\ = 9222812402616107011 D:\ = 9222812402616107013 E:\ = 9222812402616107011 F:\ = 9222812402616107011 G:\ = 9222812402616107011 H:\ = 9222812402616107013 I:\ = 9222812402616107011 This seems to have no correspondence with the API specification, and although there is a pattern, how can I be sure that these strange numbers will be consistent on other machines etc??? Thanks for your help, Tom.
-
OK I am completely new to network components in .NET (not the .NET language though...) So I was wondering what the viability is in creating a program that can directly communicate Pocket PC (iPAQ 3850) from my desktop PC in real time via the active-sync/usb connection. Can anyone direct me into the right place (like any other sample projects or where to begin etc). Thanks for ur time, this will make an interesting project, Tom
-
Quick Question - How many controls can a form have?
element replied to element's topic in Windows Forms
Cool thanks for the responses. I was only wondering that's all, like you say Alex, when you have a lot of tab pages or a wizard style interface you do use a lot of controls. Loading them into the memory when required would be a good idea for many many controls... Thanks again, Tom -
Just like the title: How many controls can a .NET Windows Form feasably hold without massive slowdown or resource hogging? Tom
-
jfackler, Thank you for your response. I did eventually manage to get it to work with this rediculous (but working) code: Dim o As Object, d As DataRowView, i As Integer = 0 For Each o In cboCDs.Items If TypeOf o Is DataRowView Then d = DirectCast(o, DataRowView) If d("tocname") = tag.CDName Then cboCDs.SelectedIndex = i Exit For End If End If i += 1 Next However I implemented your code and it works fine also, if not better ;) I did infact need to specify how my DataSet was sorted after the DataSet was loaded using this code: m_Data.ReadXml(x, XmlReadMode.ReadSchema) m_Data.Tables(CDTABLE).DefaultView.Sort = "tocname" Thanks again, Tom
-
Hi, I have a DataBound Combo box in VB.NET bound to a DataSet. It displays row data. I need to be able to modify which row is selected from code in order for my program to work properly. Basically my code returns a Row, which is from the same dataset table as the combo's bound member, which needs to be "selected". I cannot use the .SelectedItem method to do it, as it does nothing.... Thanks in advance, Tom
-
Nerseus, That looks like it is worth investigating, I shall do so after work :) Thanks for that tip, Tom
-
Thank you very much your post has been very helpful :) I've used Threading, and a Thread Delegate courtesy of: http://www.xtremedotnettalk.com/t70749.html It now loads whilst everything else is loading, so other stuff can be done at the same time. The only problem is i can start using the database before it's fully loaded, but it seems to work anyway??? I shall be using this up until I can find a way of inserting the XML source to the dataset on the fly and display progress. Maybe a way of doing this could be to load the XML source in with an XMLDOM, write the schema to the dataset, and manually add each record... Cheers, Tom