<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Getting a handle on usbprint.sys</title>
	<atom:link href="http://blog.peter.skarpetis.com/archives/2005/04/07/getting-a-handle-on-usbprintsys/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.peter.skarpetis.com/archives/2005/04/07/getting-a-handle-on-usbprintsys/</link>
	<description></description>
	<lastBuildDate>Mon, 23 May 2011 08:10:08 +1000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Administrator</title>
		<link>http://blog.peter.skarpetis.com/archives/2005/04/07/getting-a-handle-on-usbprintsys/comment-page-3/#comment-9740</link>
		<dc:creator>Administrator</dc:creator>
		<pubDate>Mon, 23 May 2011 08:10:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.peter.skarpetis.com/archives/2005/04/07/getting-a-handle-on-usbprintsys/#comment-9740</guid>
		<description>You cannot use this code for Linux or Mac. Those systems have totally different APIs so you will have to write code from scratch. The USB API for those platforms is very well documented so you should have no problem writing code to achieve the same thing on those platforms.</description>
		<content:encoded><![CDATA[<p>You cannot use this code for Linux or Mac. Those systems have totally different APIs so you will have to write code from scratch. The USB API for those platforms is very well documented so you should have no problem writing code to achieve the same thing on those platforms.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jordi Vilar</title>
		<link>http://blog.peter.skarpetis.com/archives/2005/04/07/getting-a-handle-on-usbprintsys/comment-page-3/#comment-9739</link>
		<dc:creator>Jordi Vilar</dc:creator>
		<pubDate>Mon, 23 May 2011 08:06:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.peter.skarpetis.com/archives/2005/04/07/getting-a-handle-on-usbprintsys/#comment-9739</guid>
		<description>Hi, great post!

I&#039;m trying to port a Windows code that uses usbprint to linux and mac, and I need the linux/mac replacements for IOCTL_USBPRINT_VENDOR_SET_COMMAND and IOCTL_USBPRINT_VENDOR_GET_COMMAND windows ioctl&#039;s. Any idea?

Thanks in advance</description>
		<content:encoded><![CDATA[<p>Hi, great post!</p>
<p>I&#8217;m trying to port a Windows code that uses usbprint to linux and mac, and I need the linux/mac replacements for IOCTL_USBPRINT_VENDOR_SET_COMMAND and IOCTL_USBPRINT_VENDOR_GET_COMMAND windows ioctl&#8217;s. Any idea?</p>
<p>Thanks in advance</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pooja</title>
		<link>http://blog.peter.skarpetis.com/archives/2005/04/07/getting-a-handle-on-usbprintsys/comment-page-3/#comment-9726</link>
		<dc:creator>pooja</dc:creator>
		<pubDate>Mon, 21 Feb 2011 16:52:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.peter.skarpetis.com/archives/2005/04/07/getting-a-handle-on-usbprintsys/#comment-9726</guid>
		<description>Iam trying to simulate USB printer device using microsoft&#039;s device simulation framework. When a real USB printer is pluged, two device nodes appear in windows device manager 1. USB Printing support under host controllers(USB enumarator). 2. another node with USBPRINT enumarator as explained in the following link: http://msdn.microsoft.com/en-us/library/ff560809(v=vs.85).aspx But when the simulated device pluged in only USB printing support is created. the simualted device sends the response for GET_DEVICE_ID request by sending IEEE 1284 device ID. the string is sent as unsigned char, first two bytes gives the length and rest of the string is MFG,CMD,MDL,CLS,status values. But still the second node in the device manager is not created. any other way to invoke the host to create another node?</description>
		<content:encoded><![CDATA[<p>Iam trying to simulate USB printer device using microsoft&#8217;s device simulation framework. When a real USB printer is pluged, two device nodes appear in windows device manager 1. USB Printing support under host controllers(USB enumarator). 2. another node with USBPRINT enumarator as explained in the following link: <a href="http://msdn.microsoft.com/en-us/library/ff560809(v=vs.85).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ff560809(v=vs.85).aspx</a> But when the simulated device pluged in only USB printing support is created. the simualted device sends the response for GET_DEVICE_ID request by sending IEEE 1284 device ID. the string is sent as unsigned char, first two bytes gives the length and rest of the string is MFG,CMD,MDL,CLS,status values. But still the second node in the device manager is not created. any other way to invoke the host to create another node?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: martagu</title>
		<link>http://blog.peter.skarpetis.com/archives/2005/04/07/getting-a-handle-on-usbprintsys/comment-page-3/#comment-9714</link>
		<dc:creator>martagu</dc:creator>
		<pubDate>Wed, 20 Oct 2010 12:19:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.peter.skarpetis.com/archives/2005/04/07/getting-a-handle-on-usbprintsys/#comment-9714</guid>
		<description>Thank´s a lot for your codes, I´ve tried vb6 code but when I send anything, the printer prints a page with several ASCII codes instead of real text, I´ve tried sending strings and PJL commans, could you help me, please? 
Than you a lot.</description>
		<content:encoded><![CDATA[<p>Thank´s a lot for your codes, I´ve tried vb6 code but when I send anything, the printer prints a page with several ASCII codes instead of real text, I´ve tried sending strings and PJL commans, could you help me, please?<br />
Than you a lot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: luisber</title>
		<link>http://blog.peter.skarpetis.com/archives/2005/04/07/getting-a-handle-on-usbprintsys/comment-page-3/#comment-9701</link>
		<dc:creator>luisber</dc:creator>
		<pubDate>Sat, 22 May 2010 13:15:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.peter.skarpetis.com/archives/2005/04/07/getting-a-handle-on-usbprintsys/#comment-9701</guid>
		<description>Hi, i´m tring tio traslate this code(Old Duster says: January 20, 2010 at 2:10 pm) to Visual Studio 2010 (Visual Basic) but i ´don´t have the same solution that Visual Basic 6.0, can you help me??

Public Class Form1
    

    Public Sub Command1_Click()

    End Sub
    
    Function SendToUsbPrinter(ByVal PrintOut As String) As Boolean


        Dim PrnGuid As GUID
        &#039;Dim InterfaceClassGuid As GUID
    Dim Success As Long, Ret As Long
    Dim Openned As Boolean
    Dim Buffer(256) As Byte
    Dim DeviceInterfaceData As Device_Interface_Data
    Dim FunctionClassDeviceData As Device_Interface_Detail
    Dim PnPHandle As Long, BytesReturned As Long
    Dim I As Long
    Dim DeviceName As String, DevIndex As Long, DeviceHandle As Long
    Dim ReqdSize As Long
        Dim BytesWritten As Long
        Dim d As Integer






        PrnGuid.Data4 = New Byte() {0, 1, 2, 3, 4, 5, 6, 7}
        FunctionClassDeviceData.DataPath = New Byte() {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
        &#039;Data4() = Data4({0, 1, 2, 3, 4, 5, 6, 7})
        DeviceInterfaceData.cbSize = 28
    &#039; \\?\usb#vid_0a5f&amp;pid_000a#41a081100503#{28d78fad-5a12-11d1-ae5b-0000f803a8c2}

        PrnGuid.Data1 = &amp;H28D78FAD
        PrnGuid.Data2 = &amp;H5A12
        PrnGuid.Data3 = &amp;H11D1
        PrnGuid.Data4(0) = &amp;HAE
        PrnGuid.Data4(1) = &amp;H5B
        PrnGuid.Data4(2) = &amp;H0
        PrnGuid.Data4(3) = &amp;H0
        PrnGuid.Data4(4) = &amp;HF8
        PrnGuid.Data4(5) = &amp;H3
        PrnGuid.Data4(6) = &amp;HA8
        PrnGuid.Data4(7) = &amp;HC2
       

        &#039;DeviceInterfaceData.InterfaceClassGuid.Data4 = {0, 0, 0, 0, 0, 0, 0, 0}


        PnPHandle = SetupDiGetClassDevs(PrnGuid.Data1, 0, 0, _
        DIGCF_PRESENT Or DIGCF_DEVICEINTERFACE)

        SendToUsbPrinter = False
        If (PnPHandle = -1) Then
            MsgBox(&quot;Could not attach to PnP node&quot;)
        Else
            DeviceInterfaceData.cbSize = Len(DeviceInterfaceData)
                    DevIndex = 0
            &#039; Should be a Do While -&gt; looking for the correct device-name…
            If SetupDiEnumDeviceInterfaces(PnPHandle, 0, PrnGuid.Data1, _
            DevIndex, DeviceInterfaceData.cbSize) = 0 Then

                FunctionClassDeviceData.cbSize = 5
                Success = SetupDiGetDeviceInterfaceDetail(PnPHandle, _
                DeviceInterfaceData, FunctionClassDeviceData, _
                UBound(FunctionClassDeviceData.DataPath), _
                BytesReturned, 0)
                If Success = 0 Then
                    MsgBox(&quot;Could not get the name of this device&quot;)

                Else
                    DeviceName = &quot;&quot;
                    I = 0
                    Do While FunctionClassDeviceData.DataPath(I) = 0
                        DeviceName = DeviceName &amp; _
                        Chr(FunctionClassDeviceData.DataPath(I))
                        I = I + 1

                    Loop
                    Debug.Print(DeviceName)
                    DeviceHandle = CreateFile(DeviceName, _
                    GENERIC_WRITE, FILE_SHARE_READ, _
                    0, OPEN_ALWAYS, _
                    FILE_ATTRIBUTE_NORMAL + FILE_FLAG_SEQUENTIAL_SCAN, _
                    0)
                    If (DeviceHandle = -1) Then
                        Debug.Print(&quot;Open failed on &quot; &amp; DeviceName)
                    Else
                        Ret = WriteFile(DeviceHandle, PrintOut, _
                        Len(PrintOut), BytesWritten, 0)
                        Debug.Print(&quot;Sent &quot; &amp; BytesWritten &amp; &quot; bytes.&quot;)
                        SendToUsbPrinter = True
                        CloseHandle(DeviceHandle)
                    End If
                End If
            Else
                MsgBox(&quot;Dispositvo no conectado&quot;)
            End If
                SetupDiDestroyDeviceInfoList(PnPHandle)
            End If
    End Function
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load







    End Sub



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = SendToUsbPrinter(&quot;Hello world.&quot;)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

    End Sub
End Class

Module Module1
    Public Const DIGCF_PRESENT As Integer = &amp;H2
    Public Const DIGCF_DEVICEINTERFACE As Integer = &amp;H10
    Public Const DIGCF_ALLCLASSES As Integer = &amp;H4
    Public Const GENERIC_READ = &amp;H80000000
    Public Const GENERIC_WRITE = &amp;H40000000
    Public Const FILE_FLAG_SEQUENTIAL_SCAN = &amp;H8000000
    Public Const FILE_ATTRIBUTE_HIDDEN = &amp;H2
    Public Const FILE_ATTRIBUTE_NORMAL = &amp;H80
    Public Const FILE_SHARE_READ = &amp;H1
    Public Const FILE_SHARE_WRITE = &amp;H2
    Public Const OPEN_ALWAYS = 4
    Public Const OPEN_EXISTING = 3

    Public Structure GUID

        Dim Data1 As Long
        Dim Data2 As Integer
        Dim Data3 As Integer
        Dim Data4() As Byte


    End Structure


    Public Structure Device_Interface_Data
        Dim cbSize As Long
        Dim InterfaceClassGuid As GUID
        Dim Flags As Long
        Dim ReservedPtr As Long
    End Structure

    Public Structure Device_Interface_Detail
        Dim cbSize As Long
        Dim DataPath() As Byte
    End Structure

    Public Property TextBox As Boolean
    Public Declare Function SetupDiGetDeviceInterfaceDetail _
    Lib &quot;setupapi.dll&quot; Alias &quot;SetupDiGetDeviceInterfaceDetailA&quot; _
    (ByVal DeviceInfoSet As Long, ByVal DeviceInterfaceData As Object, _
    ByVal DeviceInterfaceDetailData As Object, _
    ByVal DeviceInterfaceDetailDataSize As Long, _
    ByVal RequiredSize As Long, ByVal DeviceInfoData As Long) As Long

    Public Declare Function CreateFile Lib &quot;&quot; Alias &quot;&quot; (
    ByVal lpFileName As String, ByVal dwDesiredAccess As Long, _
    ByVal dwShareMode As Long, ByVal lpSecurityAttributes As String, _
    ByVal dwCreationDisposition As Long, _
    ByVal dwFlagsAndAttributes As Long, _
    ByVal hTemplateFile As Long) As Long

    Public Declare Sub CloseHandle Lib &quot;&quot; (ByVal HandleToClose As Long)


    Public Declare Function ReadFile Lib &quot;&quot; (ByVal Handle As Long, ByVal BufferPtr As Long, _
    ByVal ByteCount As Long, ByVal BytesReturnedPtr As Long, _
    ByVal OverlappedPtr As Long) As Long

    Public Declare Function WriteFile Lib &quot;&quot; (ByVal Handle As Long, ByVal Buffer As String, _
    ByVal ByteCount As Long, ByVal BytesReturnedPtr As Long, _
    ByVal OverlappedPtr As Long) As Long

    Public Declare Function SetupDiGetClassDevs Lib &quot;setupapi.dll&quot; _
    Alias &quot;SetupDiGetClassDevsA&quot; (ByVal GuidPtr As Long, _
    ByVal EnumPtr As Long, ByVal hwndParent As Long, _
    ByVal Flags As Long) As Long

    Public Declare Function SetupDiDestroyDeviceInfoList _
    Lib &quot;setupapi.dll&quot; _
    (ByVal DeviceInfoSet As Long) As Boolean

    Public Declare Function SetupDiEnumDeviceInterfaces _
    Lib &quot;setupapi.dll&quot; (ByVal Handle As Long, _
    ByVal InfoPtr As Long, ByVal GuidPtr As Long, _
    ByVal MemberIndex As Long, _
    ByVal InterfaceDataPtr As Long) As Boolean

End Module


thank you a lot.</description>
		<content:encoded><![CDATA[<p>Hi, i´m tring tio traslate this code(Old Duster says: January 20, 2010 at 2:10 pm) to Visual Studio 2010 (Visual Basic) but i ´don´t have the same solution that Visual Basic 6.0, can you help me??</p>
<p>Public Class Form1</p>
<p>    Public Sub Command1_Click()</p>
<p>    End Sub</p>
<p>    Function SendToUsbPrinter(ByVal PrintOut As String) As Boolean</p>
<p>        Dim PrnGuid As GUID<br />
        &#8216;Dim InterfaceClassGuid As GUID<br />
    Dim Success As Long, Ret As Long<br />
    Dim Openned As Boolean<br />
    Dim Buffer(256) As Byte<br />
    Dim DeviceInterfaceData As Device_Interface_Data<br />
    Dim FunctionClassDeviceData As Device_Interface_Detail<br />
    Dim PnPHandle As Long, BytesReturned As Long<br />
    Dim I As Long<br />
    Dim DeviceName As String, DevIndex As Long, DeviceHandle As Long<br />
    Dim ReqdSize As Long<br />
        Dim BytesWritten As Long<br />
        Dim d As Integer</p>
<p>        PrnGuid.Data4 = New Byte() {0, 1, 2, 3, 4, 5, 6, 7}<br />
        FunctionClassDeviceData.DataPath = New Byte() {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}<br />
        &#8216;Data4() = Data4({0, 1, 2, 3, 4, 5, 6, 7})<br />
        DeviceInterfaceData.cbSize = 28<br />
    &#8216; \\?\usb#vid_0a5f&amp;pid_000a#41a081100503#{28d78fad-5a12-11d1-ae5b-0000f803a8c2}</p>
<p>        PrnGuid.Data1 = &amp;H28D78FAD<br />
        PrnGuid.Data2 = &amp;H5A12<br />
        PrnGuid.Data3 = &amp;H11D1<br />
        PrnGuid.Data4(0) = &amp;HAE<br />
        PrnGuid.Data4(1) = &amp;H5B<br />
        PrnGuid.Data4(2) = &amp;H0<br />
        PrnGuid.Data4(3) = &amp;H0<br />
        PrnGuid.Data4(4) = &amp;HF8<br />
        PrnGuid.Data4(5) = &amp;H3<br />
        PrnGuid.Data4(6) = &amp;HA8<br />
        PrnGuid.Data4(7) = &amp;HC2</p>
<p>        &#8216;DeviceInterfaceData.InterfaceClassGuid.Data4 = {0, 0, 0, 0, 0, 0, 0, 0}</p>
<p>        PnPHandle = SetupDiGetClassDevs(PrnGuid.Data1, 0, 0, _<br />
        DIGCF_PRESENT Or DIGCF_DEVICEINTERFACE)</p>
<p>        SendToUsbPrinter = False<br />
        If (PnPHandle = -1) Then<br />
            MsgBox(&#8221;Could not attach to PnP node&#8221;)<br />
        Else<br />
            DeviceInterfaceData.cbSize = Len(DeviceInterfaceData)<br />
                    DevIndex = 0<br />
            &#8216; Should be a Do While -&gt; looking for the correct device-name…<br />
            If SetupDiEnumDeviceInterfaces(PnPHandle, 0, PrnGuid.Data1, _<br />
            DevIndex, DeviceInterfaceData.cbSize) = 0 Then</p>
<p>                FunctionClassDeviceData.cbSize = 5<br />
                Success = SetupDiGetDeviceInterfaceDetail(PnPHandle, _<br />
                DeviceInterfaceData, FunctionClassDeviceData, _<br />
                UBound(FunctionClassDeviceData.DataPath), _<br />
                BytesReturned, 0)<br />
                If Success = 0 Then<br />
                    MsgBox(&#8221;Could not get the name of this device&#8221;)</p>
<p>                Else<br />
                    DeviceName = &#8220;&#8221;<br />
                    I = 0<br />
                    Do While FunctionClassDeviceData.DataPath(I) = 0<br />
                        DeviceName = DeviceName &amp; _<br />
                        Chr(FunctionClassDeviceData.DataPath(I))<br />
                        I = I + 1</p>
<p>                    Loop<br />
                    Debug.Print(DeviceName)<br />
                    DeviceHandle = CreateFile(DeviceName, _<br />
                    GENERIC_WRITE, FILE_SHARE_READ, _<br />
                    0, OPEN_ALWAYS, _<br />
                    FILE_ATTRIBUTE_NORMAL + FILE_FLAG_SEQUENTIAL_SCAN, _<br />
                    0)<br />
                    If (DeviceHandle = -1) Then<br />
                        Debug.Print(&#8221;Open failed on &#8221; &amp; DeviceName)<br />
                    Else<br />
                        Ret = WriteFile(DeviceHandle, PrintOut, _<br />
                        Len(PrintOut), BytesWritten, 0)<br />
                        Debug.Print(&#8221;Sent &#8221; &amp; BytesWritten &amp; &#8221; bytes.&#8221;)<br />
                        SendToUsbPrinter = True<br />
                        CloseHandle(DeviceHandle)<br />
                    End If<br />
                End If<br />
            Else<br />
                MsgBox(&#8221;Dispositvo no conectado&#8221;)<br />
            End If<br />
                SetupDiDestroyDeviceInfoList(PnPHandle)<br />
            End If<br />
    End Function<br />
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load</p>
<p>    End Sub</p>
<p>    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
        TextBox1.Text = SendToUsbPrinter(&#8221;Hello world.&#8221;)<br />
    End Sub</p>
<p>    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click</p>
<p>    End Sub<br />
End Class</p>
<p>Module Module1<br />
    Public Const DIGCF_PRESENT As Integer = &amp;H2<br />
    Public Const DIGCF_DEVICEINTERFACE As Integer = &amp;H10<br />
    Public Const DIGCF_ALLCLASSES As Integer = &amp;H4<br />
    Public Const GENERIC_READ = &amp;H80000000<br />
    Public Const GENERIC_WRITE = &amp;H40000000<br />
    Public Const FILE_FLAG_SEQUENTIAL_SCAN = &amp;H8000000<br />
    Public Const FILE_ATTRIBUTE_HIDDEN = &amp;H2<br />
    Public Const FILE_ATTRIBUTE_NORMAL = &amp;H80<br />
    Public Const FILE_SHARE_READ = &amp;H1<br />
    Public Const FILE_SHARE_WRITE = &amp;H2<br />
    Public Const OPEN_ALWAYS = 4<br />
    Public Const OPEN_EXISTING = 3</p>
<p>    Public Structure GUID</p>
<p>        Dim Data1 As Long<br />
        Dim Data2 As Integer<br />
        Dim Data3 As Integer<br />
        Dim Data4() As Byte</p>
<p>    End Structure</p>
<p>    Public Structure Device_Interface_Data<br />
        Dim cbSize As Long<br />
        Dim InterfaceClassGuid As GUID<br />
        Dim Flags As Long<br />
        Dim ReservedPtr As Long<br />
    End Structure</p>
<p>    Public Structure Device_Interface_Detail<br />
        Dim cbSize As Long<br />
        Dim DataPath() As Byte<br />
    End Structure</p>
<p>    Public Property TextBox As Boolean<br />
    Public Declare Function SetupDiGetDeviceInterfaceDetail _<br />
    Lib &#8220;setupapi.dll&#8221; Alias &#8220;SetupDiGetDeviceInterfaceDetailA&#8221; _<br />
    (ByVal DeviceInfoSet As Long, ByVal DeviceInterfaceData As Object, _<br />
    ByVal DeviceInterfaceDetailData As Object, _<br />
    ByVal DeviceInterfaceDetailDataSize As Long, _<br />
    ByVal RequiredSize As Long, ByVal DeviceInfoData As Long) As Long</p>
<p>    Public Declare Function CreateFile Lib &#8220;&#8221; Alias &#8220;&#8221; (<br />
    ByVal lpFileName As String, ByVal dwDesiredAccess As Long, _<br />
    ByVal dwShareMode As Long, ByVal lpSecurityAttributes As String, _<br />
    ByVal dwCreationDisposition As Long, _<br />
    ByVal dwFlagsAndAttributes As Long, _<br />
    ByVal hTemplateFile As Long) As Long</p>
<p>    Public Declare Sub CloseHandle Lib &#8220;&#8221; (ByVal HandleToClose As Long)</p>
<p>    Public Declare Function ReadFile Lib &#8220;&#8221; (ByVal Handle As Long, ByVal BufferPtr As Long, _<br />
    ByVal ByteCount As Long, ByVal BytesReturnedPtr As Long, _<br />
    ByVal OverlappedPtr As Long) As Long</p>
<p>    Public Declare Function WriteFile Lib &#8220;&#8221; (ByVal Handle As Long, ByVal Buffer As String, _<br />
    ByVal ByteCount As Long, ByVal BytesReturnedPtr As Long, _<br />
    ByVal OverlappedPtr As Long) As Long</p>
<p>    Public Declare Function SetupDiGetClassDevs Lib &#8220;setupapi.dll&#8221; _<br />
    Alias &#8220;SetupDiGetClassDevsA&#8221; (ByVal GuidPtr As Long, _<br />
    ByVal EnumPtr As Long, ByVal hwndParent As Long, _<br />
    ByVal Flags As Long) As Long</p>
<p>    Public Declare Function SetupDiDestroyDeviceInfoList _<br />
    Lib &#8220;setupapi.dll&#8221; _<br />
    (ByVal DeviceInfoSet As Long) As Boolean</p>
<p>    Public Declare Function SetupDiEnumDeviceInterfaces _<br />
    Lib &#8220;setupapi.dll&#8221; (ByVal Handle As Long, _<br />
    ByVal InfoPtr As Long, ByVal GuidPtr As Long, _<br />
    ByVal MemberIndex As Long, _<br />
    ByVal InterfaceDataPtr As Long) As Boolean</p>
<p>End Module</p>
<p>thank you a lot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Extrarius</title>
		<link>http://blog.peter.skarpetis.com/archives/2005/04/07/getting-a-handle-on-usbprintsys/comment-page-3/#comment-9699</link>
		<dc:creator>Extrarius</dc:creator>
		<pubDate>Fri, 14 May 2010 16:10:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.peter.skarpetis.com/archives/2005/04/07/getting-a-handle-on-usbprintsys/#comment-9699</guid>
		<description>Thank you Peter for this information. I was pretty sure I&#039;d wasted money after tons of googling turned up only complaints about misleading labeling, but then I finally found this site and all is saved! =-)

I wonder how hard it&#039;d be to make a driver that provided the normal parallel port interface to one of these &quot;Parallel Printer Cable&quot;s.

With the &quot;USB to (not really) Parallel Port Cable&quot; I bought for electronics projects, I got WriteFile to return by grounding the BUSY pin (see wikipedia or any number of other sites for pin definitions) and pulsing the ACK pin. Somebody suggested just grounding ACK, but that only worked for a single byte - I&#039;m guessing the circuit in my cable checks both edges of the ACK signal.
Another site suggested connecting ACK to STROBE, and that seems to work OK for a few bytes, but then I guess the in-cable microcontroller misses the ACK, because it&#039;ll stop sending after a few bytes. I haven&#039;t tried it yet, but I&#039;m thinking that connecting STROBE to the input of a monostable multivibrator and the output of that to ACK will fix the problem by extending the pulse duration (unless I&#039;m completely wrong and that isn&#039;t the problem).</description>
		<content:encoded><![CDATA[<p>Thank you Peter for this information. I was pretty sure I&#8217;d wasted money after tons of googling turned up only complaints about misleading labeling, but then I finally found this site and all is saved! =-)</p>
<p>I wonder how hard it&#8217;d be to make a driver that provided the normal parallel port interface to one of these &#8220;Parallel Printer Cable&#8221;s.</p>
<p>With the &#8220;USB to (not really) Parallel Port Cable&#8221; I bought for electronics projects, I got WriteFile to return by grounding the BUSY pin (see wikipedia or any number of other sites for pin definitions) and pulsing the ACK pin. Somebody suggested just grounding ACK, but that only worked for a single byte &#8211; I&#8217;m guessing the circuit in my cable checks both edges of the ACK signal.<br />
Another site suggested connecting ACK to STROBE, and that seems to work OK for a few bytes, but then I guess the in-cable microcontroller misses the ACK, because it&#8217;ll stop sending after a few bytes. I haven&#8217;t tried it yet, but I&#8217;m thinking that connecting STROBE to the input of a monostable multivibrator and the output of that to ACK will fix the problem by extending the pulse duration (unless I&#8217;m completely wrong and that isn&#8217;t the problem).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: alen</title>
		<link>http://blog.peter.skarpetis.com/archives/2005/04/07/getting-a-handle-on-usbprintsys/comment-page-3/#comment-9692</link>
		<dc:creator>alen</dc:creator>
		<pubDate>Mon, 26 Apr 2010 13:54:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.peter.skarpetis.com/archives/2005/04/07/getting-a-handle-on-usbprintsys/#comment-9692</guid>
		<description>I just can&#039;t return in WriteFile(), it&#039;s blocked.
I can get \\?\USB name use peter&#039;s  GUID and SetupDi functions,no error with CreateFile() ,but when I call Deviceiocontrol() or WriteFile() it&#039;s blocked and no return. I don&#039;t attach a printer , I just plug in the USB to Parallel cable, is it necessary to attach a printer with the cable for all things work ?</description>
		<content:encoded><![CDATA[<p>I just can&#8217;t return in WriteFile(), it&#8217;s blocked.<br />
I can get \\?\USB name use peter&#8217;s  GUID and SetupDi functions,no error with CreateFile() ,but when I call Deviceiocontrol() or WriteFile() it&#8217;s blocked and no return. I don&#8217;t attach a printer , I just plug in the USB to Parallel cable, is it necessary to attach a printer with the cable for all things work ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MC_Boy</title>
		<link>http://blog.peter.skarpetis.com/archives/2005/04/07/getting-a-handle-on-usbprintsys/comment-page-3/#comment-9689</link>
		<dc:creator>MC_Boy</dc:creator>
		<pubDate>Thu, 01 Apr 2010 20:32:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.peter.skarpetis.com/archives/2005/04/07/getting-a-handle-on-usbprintsys/#comment-9689</guid>
		<description>I&#039;m not using the LPT to use a printer the software that i use is to control an osciloscope and it needs to have an address like 278, 378 or 3BC to run ok.

What do i have to do?</description>
		<content:encoded><![CDATA[<p>I&#8217;m not using the LPT to use a printer the software that i use is to control an osciloscope and it needs to have an address like 278, 378 or 3BC to run ok.</p>
<p>What do i have to do?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Narayanan</title>
		<link>http://blog.peter.skarpetis.com/archives/2005/04/07/getting-a-handle-on-usbprintsys/comment-page-3/#comment-9687</link>
		<dc:creator>Narayanan</dc:creator>
		<pubDate>Wed, 24 Mar 2010 14:32:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.peter.skarpetis.com/archives/2005/04/07/getting-a-handle-on-usbprintsys/#comment-9687</guid>
		<description>Dear All,

I am programming a Printer monitoring tool for HP USB Deskjets in .Net.

I could use SetupDiGetClassDevs(..),  SetupDiEnumDeviceInterfaces(..) etc. to obtain the Symbolic Name of the devices which are connected to the PC, but i am not yet successful in obtaining the Friendly name from the Symbolic name. The friendly names are the names which are displayed in &quot;Printers and Faxes&quot;. 

For you ref the symbolic names are of the form

\??\USB#Vid_03f0&amp;Pid_6545#0000000002310#{a5dcbf10-6530-11d2-901f-00c04fb951ed} 

I would be very glad and thankful if someone could help me by pointing the correct method or steps to follow if possible with a snippet.
 
Best regards

Narayanan</description>
		<content:encoded><![CDATA[<p>Dear All,</p>
<p>I am programming a Printer monitoring tool for HP USB Deskjets in .Net.</p>
<p>I could use SetupDiGetClassDevs(..),  SetupDiEnumDeviceInterfaces(..) etc. to obtain the Symbolic Name of the devices which are connected to the PC, but i am not yet successful in obtaining the Friendly name from the Symbolic name. The friendly names are the names which are displayed in &#8220;Printers and Faxes&#8221;. </p>
<p>For you ref the symbolic names are of the form</p>
<p>\??\USB#Vid_03f0&amp;Pid_6545#0000000002310#{a5dcbf10-6530-11d2-901f-00c04fb951ed} </p>
<p>I would be very glad and thankful if someone could help me by pointing the correct method or steps to follow if possible with a snippet.</p>
<p>Best regards</p>
<p>Narayanan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: alex</title>
		<link>http://blog.peter.skarpetis.com/archives/2005/04/07/getting-a-handle-on-usbprintsys/comment-page-3/#comment-9686</link>
		<dc:creator>alex</dc:creator>
		<pubDate>Fri, 19 Mar 2010 03:21:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.peter.skarpetis.com/archives/2005/04/07/getting-a-handle-on-usbprintsys/#comment-9686</guid>
		<description>firts of all thanks for the code, is exelent, and thanks too, for reply to me so quickly...
I manage to have succes in get it done the code you post, but the problem is that i dont really need print anything, what i really want is send a signal and control the way is sended for example make the pin 6, 7, 8, 9 turn on(leds conected to the lpt out in a cable USB-PARALLEL)

I really sorry if my english is bad.....i am spanish speaker.....</description>
		<content:encoded><![CDATA[<p>firts of all thanks for the code, is exelent, and thanks too, for reply to me so quickly&#8230;<br />
I manage to have succes in get it done the code you post, but the problem is that i dont really need print anything, what i really want is send a signal and control the way is sended for example make the pin 6, 7, 8, 9 turn on(leds conected to the lpt out in a cable USB-PARALLEL)</p>
<p>I really sorry if my english is bad&#8230;..i am spanish speaker&#8230;..</p>
]]></content:encoded>
	</item>
</channel>
</rss>

