Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Pinvoking a non WIN32 API under VB, cant get handle to printer

Pinvoking a non WIN32 API under VB, cant get handle to printer

Scheduled Pinned Locked Moved Visual Basic
helpcsharpjsontutorial
25 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Hrizip

    No idea why I implemented loadlibrary, when I started working on this project first I tried to translate c code to vb code practically line by line, loadlibrary was the first thing on the way. I didnt think it might wreak havoc when combined with pinvoking , I will be removing it to see what happens. I have already tried your solution - it didnt work. I always get hPrinter returned as "0". I simply cant get the printer to return a valid handle. There is no way of finding out whether the dll communicates with the printer, therefore I cannot figure out what this 0 I get returned means, does it mean that no printer was found or something else? With no way of knowing how (and if) the dll, in itself, communicates with the hardware, I cant troubleshoot this.

    L Offline
    L Offline
    Luc Pattyn
    wrote on last edited by
    #21

    while there isn't much text in the manual, the way I understand the available information is: 1. you need to install your printer and its driver somehow; that should result in it being visible in the list of installed printers. 2. your program needs to start with a GetHandle, which returns success/failure and an error code on failure. Those should be self-explanatory. The one thing .NET adds here is some uncertainty about the P/Invoke stuff, due to gaps in the doc, not shortcomings of .NET Therefore: 1. do you see your printer in say MS Word? 2. could you try the C example? Once those two work well, getting VB.NET up and printing should be simple. :)

    Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

    Please use < PRE > tags for code snippets, it preserves indentation, and improves readability.

    H 1 Reply Last reply
    0
    • L Luc Pattyn

      while there isn't much text in the manual, the way I understand the available information is: 1. you need to install your printer and its driver somehow; that should result in it being visible in the list of installed printers. 2. your program needs to start with a GetHandle, which returns success/failure and an error code on failure. Those should be self-explanatory. The one thing .NET adds here is some uncertainty about the P/Invoke stuff, due to gaps in the doc, not shortcomings of .NET Therefore: 1. do you see your printer in say MS Word? 2. could you try the C example? Once those two work well, getting VB.NET up and printing should be simple. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

      Please use < PRE > tags for code snippets, it preserves indentation, and improves readability.

      H Offline
      H Offline
      Hrizip
      wrote on last edited by
      #22

      USB interface - tested, can print, can use windows driver, cant use my app, cant use SDK app Ethernet interface - tested, can print, can use win driver, cant use my app, cant use SDK app This was tested on both win 7 and win Vista, I also tried it on VMWARE windows XP SP2 but it crashed immidiately, but possible due to virtualization itself. Tomorrow I will try it on "pure" Windows XP, but I dont expect much.

      L 1 Reply Last reply
      0
      • H Hrizip

        USB interface - tested, can print, can use windows driver, cant use my app, cant use SDK app Ethernet interface - tested, can print, can use win driver, cant use my app, cant use SDK app This was tested on both win 7 and win Vista, I also tried it on VMWARE windows XP SP2 but it crashed immidiately, but possible due to virtualization itself. Tomorrow I will try it on "pure" Windows XP, but I dont expect much.

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #23

        from that information, I would focus on a real XP system, no virtualization, no UAC stuff. Vista & 7 keep regular users away from protected data, you can't even get a disk's serial number as that requires an OpenFile(mydisk). If that turns out to be the problem, the manufacturer will be bound to come up with a solution, as the Windows world is slowly moving to Vista/7 and they can't ignore that. FWIW: and the error code(s) should be more informative! :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

        Please use < PRE > tags for code snippets, it preserves indentation, and improves readability.

        H 1 Reply Last reply
        0
        • L Luc Pattyn

          from that information, I would focus on a real XP system, no virtualization, no UAC stuff. Vista & 7 keep regular users away from protected data, you can't even get a disk's serial number as that requires an OpenFile(mydisk). If that turns out to be the problem, the manufacturer will be bound to come up with a solution, as the Windows world is slowly moving to Vista/7 and they can't ignore that. FWIW: and the error code(s) should be more informative! :)

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

          Please use < PRE > tags for code snippets, it preserves indentation, and improves readability.

          H Offline
          H Offline
          Hrizip
          wrote on last edited by
          #24

          Their SDK is from 2007, done in C, and their support people havent responded to my queries yet, I wont hold my breath ;) If we had known we would have gone with a different manufacturer.

          1 Reply Last reply
          0
          • H Hrizip

            And here is the SDK manual for those who may find it interesting, the same web page also hosts the entire SDK. http://support.online-dubai.com/embu/Zebra/ZEBRA%20CARD%20PRINTERS/Technical/PrinterSetup_v2.06.04/program%20files/Zebra%20Technologies/Zebra%20SDK/Zebra%20SDK%20Reference%20Manual/SDKReferenceManual.pdf

            H Offline
            H Offline
            Hrizip
            wrote on last edited by
            #25

            It (SDK example) crashes with no relevant error code even on "pure" windows XP SP2 machine which normally accesses the printer. I have (finally) been contacted by Zebra support, they have given me an email address, which unfortunately does not exist.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups