|
-
May 21st, 2000, 07:38 PM
#1
Thread Starter
New Member
I would like to add a printer with the addprinter api but:
Here is the declaration in C++:
HANDLE AddPrinter( LPTSTR pName, // pointer to server name
DWORD Level, // printer info. structure level
LPBYTE pPrinter // pointer to structure);
here is my declaration in VB:
Declare Function AddPrinter Lib "winspool.drv" Alias "AddPrinterA" (ByVal pName As String, ByVal Level As Long, pPrinter As any) As Long
I call the API like that, before I have fill in the Printer_Info_2 structure:
ReturnValue = AddPrinter("", 2, PrtInfo)
Return Value is a long, PrtInfo is a Printer_Info_2 structure.
But this API doesn't work at all, I think there is a problem with the pPrinter parametre but I'm not sure...
Does someone help me quick please???
Thank You
-
May 22nd, 2000, 01:07 AM
#2
Because PrtInfo is a structure, when you pass it you're passing a pointer to the first item in the structure (I think), rather than a pointer to the structure of pointers. Try passing the address explicitly like
Dim ptrPrinter as long
ptrPrinter = ObjPtr(PrtInfo)
ReturnValue = AddPrinter("", 2, ptrPrinter)
-
May 22nd, 2000, 01:52 PM
#3
Thread Starter
New Member
I have tried to pass the address like you wrote it here but it seems that the ObjPtr() function doesn't accept my PrtInfo structure, when I Lauch the Api VB make a type mismatch error.
I'm almost sure you're right, I have to pass the address but
how can I do that if the ObjPtr() function doesn't work???
Thank You.
-
May 23rd, 2000, 08:56 PM
#4
Sorry, It's one of these:
VarPtr - Returns the address of a variable.
VarPtrArray - Returns the address of an array.
StrPtr - Returns the address of the UNICODE string buffer.
VarPtrStringArray - Returns the address of an array of strings.
ObjPtr - Returns the pointer to the interface referenced by an object variable.
John
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|