I am needing to get the ip of the printer but am not having much success. Already tried in various ways. Currently my code is like 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 he tries to call the XcvData function she not enter the 'IF'. And my object "wAddress" remains empty. Because I'm not getting?
OBS: This code is based on the msdn doc: http://msdn.microsoft.com/en-us/library/windows/hardware/ff562761(v=vs.85).aspx
Thank!
You're missing the server name in the OpenPrinter
call. The printer name should look something like this:
"\\\\myServer\\,XvcPort myPort"
To confirm that is the problem, call GetLastError
when OpenPrinter
fails.