Pinvoking a non WIN32 API under VB, cant get handle to printer
-
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.
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.
-
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.
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.
-
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.
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.
-
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.
-
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