Sign in to follow this  
Followers 0
ChrisL

Pointer of an Array in DLLCALL

8 posts in this topic

[Function] DWORD MCP_EnumPrinter(PUINT puiNumPrinter, PHANDLE phPrinter)

[Description] Find and list printers to be controlled.

[Arguments] IN Maximum number of printer handles that can be

acquired.

puiNumPrinter

OUT Number of printer handles that can be found.

phPrinter OUT Pointer of an array in which printer handles

should be stored.

This kind of works but the 0 at the end should point to an array but I guess not an Autoit array

$MCP_MAX_OPEN_PRINTER = 3
$ret = DllCall($dll, "DWORD", "MCP_EnumPrinter", "int*", $MCP_MAX_OPEN_PRINTER, "long*", 0)

$ret[2] always has the first printer handle but no subsequent handles, the second printer can be accessed by using a handle $h = $Ret[2] +1 but I don't think it is the right way to do it.

Any ideas on what the 0 should be and possibly the long*

Thanks

Share this post


Link to post
Share on other sites



Try:

$MCP_MAX_OPEN_PRINTER = 3
$tHandles = DllStructCreate("ptr[" & $MCP_MAX_OPEN_PRINTER & "]")
$ret = DllCall($dll, "dword", "MCP_EnumPrinter", "dword*", $MCP_MAX_OPEN_PRINTER, "ptr", DllStructGetPtr($tHandles))

For $i = 1 To $MCP_MAX_OPEN_PRINTER
    ConsoleWrite("pointer " & $i & " = " & DllStructGetData($tHandles, $i) & @CRLF)
Next

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

How can we test this without adequate details? A search for "MCP_EnumPrinter" finds nothing on Google.

Share this post


Link to post
Share on other sites

How can we test this without adequate details? A search for "MCP_EnumPrinter" finds nothing on Google.

MCP_EnumPrinter wouldn't come up with anything on Google, its a printer made by the company I work for and the information at the top of the page is straight out of the SDK manual.

I didn't understand the pointer to an array because it wasn't refering to an Autoit style array. I'm still not convinced after trancexx last post that it is quite right because now I get 0100001 and 0100002 which is almost correct but not a handle to the printers but it is further than I got before without his help.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Unfortunately that doesn't work

It returns for 2 printers

0x0100001

0

0

0

0

0

0

0

Any other ideas?

Try this code

$MCP_MAX_OPEN_PRINTER = 3
$ret = DllCall($dll, "dword", "MCP_EnumPrinter", "dword*", $MCP_MAX_OPEN_PRINTER, "ptr*",0)
$tHandles = DllStructCreate("HANDLE[" & $MCP_MAX_OPEN_PRINTER & "]",$ret[2])

For $i = 1 To $MCP_MAX_OPEN_PRINTER
    ConsoleWrite("HANDLE " & $i & " = " & DllStructGetData($tHandles, $i) & @CRLF)
Next
Edited by wolf9228

صرح السماء كان هنا

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0