c++ - Getting IPAddress with XcvData -
i needing ip of printer not having success. tried in various ways. code this:
void spl::getipaddress(lpstr printername) { handle hprinter; pbyte waddress = null; dword size; dword status; lpstr portname = getprot(printername); std::ostringstream strtemp; strtemp << portname; string temp = ",xcvport " + strtemp.str(); //temp = ,xcvport 192.168.2.247 lpstr templpstr((lpstr)temp.c_str()); if(openprinter(templpstr,&hprinter,null)) { if (xcvdata(hprinter, l"ipaddress", null, 0,waddress,31, &size,&status)) { } } }
when tries call xcvdata function not enter 'if'. , object "waddress" remains empty. because i'm not getting?
obs: code based on msdn doc: http://msdn.microsoft.com/en-us/library/windows/hardware/ff562761(v=vs.85).aspx
thank!
you're missing server name in openprinter
call. printer name should this:
"\\\\myserver\\,xvcport myport"
to confirm problem, call getlasterror
when openprinter
fails.
Comments
Post a Comment