Any idea what could be the difference with the "Local Port" that I create
thru code and the manual one? There must be something else that I needd to
do, when I create the port in the code.
Thanks,
Farid
======= Code to create port =========
HANDLE hXVCPrinter = NULL ;
LPWSTR wsPortName = L"eefPort:";
DWORD dwNeeded, dwStatus;
PRINTER_DEFAULTS PrinterDefaults;
PrinterDefaults.pDatatype = NULL;
PrinterDefaults.pDevMode = NULL;
PrinterDefaults.DesiredAccess = SERVER_ACCESS_ADMINISTER;
if (OpenPrinter(L",XcvMonitor Local Port", &hXVCPrinter,
&PrinterDefaults))
{
dwError = ERROR_SUCCESS;
if (!XcvData(hXVCPrinter, L"AddPort", (LPBYTE)wsPortName,
(wcslen(wsPortName)+1)*2, NULL, 0, &dwNeeded, &dwStatus) ||
!(dwStatus == ERROR_SUCCESS || dwStatus == ERROR_ALREADY_EXISTS))
{
dwError = GetLastError();
wsprintf(sMessage, L"XcvData: Error = %d - Status = %d", dwError,
dwStatus);
MyMessageBox(sMessage, EEFPPROC_MSGBOX_TITLE, MB_OK);
}
else
{
wsprintf(sMessage, L"Port added successfully. - Status = %d - Port:
%s", dwStatus, wsPortName);
MyMessageBox(sMessage, EEFPPROC_MSGBOX_TITLE, MB_OK);
}
ClosePrinter(hXVCPrinter);
}
else
{
dwError = GetLastError();
wsprintf(sMessage, L"OpenPrinter: Error = %d", dwError);
MyMessageBox(sMessage, EEFPPROC_MSGBOX_TITLE, MB_OK);
}