Click here to Skip to main content
15,914,165 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Pinvoking a non WIN32 API under VB, cant get handle to printer Pin
Hrizip29-Jun-10 4:31
Hrizip29-Jun-10 4:31 
AnswerRe: Pinvoking a non WIN32 API under VB, cant get handle to printer Pin
Luc Pattyn29-Jun-10 4:34
sitebuilderLuc Pattyn29-Jun-10 4:34 
GeneralRe: Pinvoking a non WIN32 API under VB, cant get handle to printer Pin
Hrizip29-Jun-10 4:36
Hrizip29-Jun-10 4:36 
AnswerRe: Pinvoking a non WIN32 API under VB, cant get handle to printer Pin
Luc Pattyn29-Jun-10 7:41
sitebuilderLuc Pattyn29-Jun-10 7:41 
GeneralRe: Pinvoking a non WIN32 API under VB, cant get handle to printer Pin
Hrizip29-Jun-10 7:58
Hrizip29-Jun-10 7:58 
GeneralRe: Pinvoking a non WIN32 API under VB, cant get handle to printer Pin
Luc Pattyn29-Jun-10 8:26
sitebuilderLuc Pattyn29-Jun-10 8:26 
GeneralRe: Pinvoking a non WIN32 API under VB, cant get handle to printer Pin
Hrizip29-Jun-10 8:34
Hrizip29-Jun-10 8:34 
GeneralRe: Pinvoking a non WIN32 API under VB, cant get handle to printer Pin
Luc Pattyn29-Jun-10 8:52
sitebuilderLuc Pattyn29-Jun-10 8:52 
I looked in the manual (ZBRGetHandle defined on p12 , example p219), and I now see:
- the Handle is going to be returned, so it must be ByRef after all.
- passing the name should be no problem at all, a simple string is all it takes, not even a StringBuilder;
- strangely enough printerType is an int and needs being passed by reference (don't see why).

So I'll go for:

    Dim hPrinter As IntPtr 
    Dim printerType As Integer = 330
    Dim err As Integer = 0

    Dim ret As IntPtr = ZBRGetHandle(hPrinter, "Zebra P330i USB Card Printer", printerType, err)


<DllImport("ZBRPrinter.dll")>
Public Shared Function ZBRGetHandle(ByRef hPrinter As IntPtr, ByVal pName As String, ByRef printerType As Integer, ByRef err As Integer) As IntPtr
    End Function


What I do not understand is why you load the DLL first, see your LoadLibrary.
P/Invoke does not need (not even want?) that, and the DLL must be found by regular Windows PATH scanning.

Smile | :)
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.


GeneralRe: Pinvoking a non WIN32 API under VB, cant get handle to printer Pin
Hrizip29-Jun-10 9:12
Hrizip29-Jun-10 9:12 
GeneralRe: Pinvoking a non WIN32 API under VB, cant get handle to printer Pin
Luc Pattyn29-Jun-10 10:03
sitebuilderLuc Pattyn29-Jun-10 10:03 
GeneralRe: Pinvoking a non WIN32 API under VB, cant get handle to printer Pin
Hrizip29-Jun-10 10:17
Hrizip29-Jun-10 10:17 
GeneralRe: Pinvoking a non WIN32 API under VB, cant get handle to printer Pin
Luc Pattyn29-Jun-10 10:26
sitebuilderLuc Pattyn29-Jun-10 10:26 
GeneralRe: Pinvoking a non WIN32 API under VB, cant get handle to printer Pin
Hrizip29-Jun-10 10:29
Hrizip29-Jun-10 10:29 
GeneralRe: Pinvoking a non WIN32 API under VB, cant get handle to printer Pin
Hrizip29-Jun-10 8:17
Hrizip29-Jun-10 8:17 
GeneralRe: Pinvoking a non WIN32 API under VB, cant get handle to printer Pin
Hrizip30-Jun-10 23:28
Hrizip30-Jun-10 23:28 
QuestionMDI window application with treeview by visual basic 2005 Pin
Andraw Tang28-Jun-10 9:03
Andraw Tang28-Jun-10 9:03 
AnswerRe: MDI window application with treeview by visual basic 2005 Pin
Dave Kreskowiak28-Jun-10 10:46
mveDave Kreskowiak28-Jun-10 10:46 
GeneralRe: MDI window application with treeview by visual basic 2005 Pin
Andraw Tang28-Jun-10 11:20
Andraw Tang28-Jun-10 11:20 
GeneralRe: MDI window application with treeview by visual basic 2005 Pin
Dave Kreskowiak28-Jun-10 14:09
mveDave Kreskowiak28-Jun-10 14:09 
GeneralRe: MDI window application with treeview by visual basic 2005 Pin
Andraw Tang28-Jun-10 11:39
Andraw Tang28-Jun-10 11:39 
GeneralRe: MDI window application with treeview by visual basic 2005 Pin
Dave Kreskowiak28-Jun-10 14:23
mveDave Kreskowiak28-Jun-10 14:23 
GeneralRe: MDI window application with treeview by visual basic 2005 Pin
Andraw Tang29-Jun-10 3:18
Andraw Tang29-Jun-10 3:18 
GeneralRe: MDI window application with treeview by visual basic 2005 Pin
Dave Kreskowiak29-Jun-10 5:14
mveDave Kreskowiak29-Jun-10 5:14 
GeneralRe: MDI window application with treeview by visual basic 2005 Pin
Andraw Tang29-Jun-10 5:23
Andraw Tang29-Jun-10 5:23 
QuestionVisual Basic 2005 and VB.NET 2005 Pin
Andraw Tang28-Jun-10 5:49
Andraw Tang28-Jun-10 5:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.