Using EasyHID with VBExpress 2005 (maybe .NET as well)


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Thank you Steve and David.

    The VB5/Express part was my hold up.
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Thanks guys, don't forget to post your "It's working or not" comments...

    As i write it, (~24 hours later) the template have been downloaded 76 times already

    Finger crossed
    Last edited by mister_e; - 7th June 2007 at 02:13.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Feb 2007
    Posts
    2


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Have been playing with this and it works great.

    Only thing is that I can not get hidGetVendorName and hidGetProductName to work. I get an "Attempted to read or write protected memory" error with this and i'm not sure if im doing something wrong or that theres a problem with this .net version.

    Thanks
    Abnormal1

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Yup, Yet another .NET thingy. 'Till now, i have found a way to make it work....
    Code:
       Public Sub OnPlugged(ByVal pHandle As Integer)
        Dim DeviceHandle As Integer
                                  ' Mister E 
        Dim VendorName As String = "         "
                                   ' USB Demo
        Dim ProductName As String = "         "
    
        If hidGetVendorID(pHandle) = VendorID And hidGetProductID(pHandle) = ProductID Then ' Good one?
            '
            '   get the device handle
            '   =====================
            DeviceHandle = hidGetHandle(VendorID, ProductID)
            '
            '   Get the vendor and product name from the handle
            '   ===============================================
            hidGetVendorName(DeviceHandle, VendorName, 255)
            hidGetProductName(DeviceHandle, ProductName, 255)
            End If
        Label2.Text = VendorName
        label3.text = ProductName
    The trick is to assign a value to VendorName and ProductName before calling hidGetVendorName and hidGetProductName. Make sure your space/blank character are at least equal to the LEN if VendorName and ProductName. Unless, it will screw up things.

    VB.NET doesn't seems to have a way to determine a fixed String size...

    Anyways, i've ask the question on the MSDN forum, let's see if there's a more elegant way to do it. It has to... In meantime, the above solution work.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Feb 2007
    Posts
    2


    Did you find this post helpful? Yes | No

    Default

    Thanks for that, it now works.

    I expected it to be related to not using a fixed length string, however I had only tried to set the strings to Null rather than a load of spaces.

    Anyway I have found that using the following is easier than counting how many time you press the spacebar
    Code:
    Dim VendorName As String = New String(CChar(" "), 16)

    Also in the code you posted I don't think that you need to call "hidGetHandle" as you already have that in the variable "pHandle".

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    here's a way to assign a fixed format string in dotnet

    [HTML]<VBFixedString(15)> Public VendorName As String[/HTML]

    you still need to load with character it so far... don't forget the Imports Sytem

    Guys over there send me few links. Load of thing to learn/try with this new .NET. (marshallxxx, exception.. syntax, InteropService.. etc etc etc). Especially when dealing with API

    I've also found few nice .CHM and .PDF on VB.NET and Express... RTFM sessions will begin... when i'll wake up. <hr>

    EOM

    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Amr Bekhit has modified it a little bit and added some documentation as well

    USB HID Template for Visual Basic 2005
    http://www.helmpcb.com/Software/USBHIDVB/USBHIDVB.aspx
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Replies: 4
    Last Post: - 5th November 2008, 16:21
  2. Problem with enumeration and EasyHID
    By jizyjuice in forum USB
    Replies: 22
    Last Post: - 9th April 2007, 20:40
  3. EasyHID and VB.net
    By NL2TTL in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 14th September 2006, 05:40
  4. HIDMakerFS versus EasyHID
    By Demon in forum USB
    Replies: 4
    Last Post: - 15th August 2006, 08:01
  5. Replies: 0
    Last Post: - 5th September 2005, 09:09

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts