We are trying to send a command to a printer to wake it up using c++
We are using the fargo hdp5000 printer sdk. Has anyone used this sdk fargoNativeAPI.dll? Is it possible to send a wakeup without the SDK. Also, I have the printer emulator running but I can tell if the command is being sent. Are there low level logs on Windows to see what is happening.
<code> std::cout << "Loading FargoNativeAPIn" << std::endl;
hinstLib = LoadLibrary(L"D:/util/projects2/rapids/bin/FargoNativeAPI.dll");
if (hinstLib != NULL)
{
std::cout << "Loaded FargoNativeAPI successfully...n" << std::endl;
pCreateDiagnosticsUtilW = (CreateDiagnosticsUtilW)GetProcAddress(hinstLib, "CreateDiagnosticsUtilW");
pDestroyDiagnosticsUtilW = (DestroyDiagnosticsUtil)GetProcAddress(hinstLib, "DestroyDiagnosticsUtil");
pDiagnosticsUtil_WakeUpPrinter = (DiagnosticsUtil_WakeUpPrinter)GetProcAddress(hinstLib, "DiagnosticsUtil_WakeUpPrinter");
if ((NULL != pCreateDiagnosticsUtilW) && (NULL != pDiagnosticsUtil_WakeUpPrinter))
{
std::cout << "Getting Printer Name...n" << std::endl;
const char* printerStr = "HDP5000 Card Printer";
int bufferSize = MultiByteToWideChar(CP_UTF8, 0, printerStr, -1, NULL, 0);
wchar_t* pPrinterName = new wchar_t[bufferSize];
MultiByteToWideChar(CP_UTF8, 0, printerStr, -1, pPrinterName, bufferSize);
std::cout << "Done getting Printer Name...n" << std::endl;
pDiagnosticsUtil = (pCreateDiagnosticsUtilW)((LPWSTR)pPrinterName);
//PVOID pDiagnosticsUtil = pCreateDiagnosticsUtilW(pPrinterName);
std::cout << GetLastErrorAsString() << std::endl;
if (NULL != pDiagnosticsUtil)
{
pDiagnosticsUtil_WakeUpPrinter(pDiagnosticsUtil);
std::cout << GetLastErrorAsString() << std::endl;
pDestroyDiagnosticsUtilW(pDiagnosticsUtil);
delete[] pPrinterName;
}
else
{
delete[] pPrinterName;
std::cout << "Problem instantiating pDiagnostics!n" << std::endl;
}
}
FreeLibrary(hinstLib);
}
else
{
std::cout << "Problem loading FargoNativeAPI!n" << std::endl;
}
std::cout << "nDone calling Fargo WakeUp Command";
}
catch (...)
{
// catch any other errors (that we have no information about)
std::cerr << "Unknown failure occurred. Possible memory corruption" << std::endl;
}
return status;
</code>
<code> std::cout << "Loading FargoNativeAPIn" << std::endl;
hinstLib = LoadLibrary(L"D:/util/projects2/rapids/bin/FargoNativeAPI.dll");
if (hinstLib != NULL)
{
std::cout << "Loaded FargoNativeAPI successfully...n" << std::endl;
pCreateDiagnosticsUtilW = (CreateDiagnosticsUtilW)GetProcAddress(hinstLib, "CreateDiagnosticsUtilW");
pDestroyDiagnosticsUtilW = (DestroyDiagnosticsUtil)GetProcAddress(hinstLib, "DestroyDiagnosticsUtil");
pDiagnosticsUtil_WakeUpPrinter = (DiagnosticsUtil_WakeUpPrinter)GetProcAddress(hinstLib, "DiagnosticsUtil_WakeUpPrinter");
if ((NULL != pCreateDiagnosticsUtilW) && (NULL != pDiagnosticsUtil_WakeUpPrinter))
{
std::cout << "Getting Printer Name...n" << std::endl;
const char* printerStr = "HDP5000 Card Printer";
int bufferSize = MultiByteToWideChar(CP_UTF8, 0, printerStr, -1, NULL, 0);
wchar_t* pPrinterName = new wchar_t[bufferSize];
MultiByteToWideChar(CP_UTF8, 0, printerStr, -1, pPrinterName, bufferSize);
std::cout << "Done getting Printer Name...n" << std::endl;
pDiagnosticsUtil = (pCreateDiagnosticsUtilW)((LPWSTR)pPrinterName);
//PVOID pDiagnosticsUtil = pCreateDiagnosticsUtilW(pPrinterName);
std::cout << GetLastErrorAsString() << std::endl;
if (NULL != pDiagnosticsUtil)
{
pDiagnosticsUtil_WakeUpPrinter(pDiagnosticsUtil);
std::cout << GetLastErrorAsString() << std::endl;
pDestroyDiagnosticsUtilW(pDiagnosticsUtil);
delete[] pPrinterName;
}
else
{
delete[] pPrinterName;
std::cout << "Problem instantiating pDiagnostics!n" << std::endl;
}
}
FreeLibrary(hinstLib);
}
else
{
std::cout << "Problem loading FargoNativeAPI!n" << std::endl;
}
std::cout << "nDone calling Fargo WakeUp Command";
}
catch (...)
{
// catch any other errors (that we have no information about)
std::cerr << "Unknown failure occurred. Possible memory corruption" << std::endl;
}
return status;
</code>
std::cout << "Loading FargoNativeAPIn" << std::endl;
hinstLib = LoadLibrary(L"D:/util/projects2/rapids/bin/FargoNativeAPI.dll");
if (hinstLib != NULL)
{
std::cout << "Loaded FargoNativeAPI successfully...n" << std::endl;
pCreateDiagnosticsUtilW = (CreateDiagnosticsUtilW)GetProcAddress(hinstLib, "CreateDiagnosticsUtilW");
pDestroyDiagnosticsUtilW = (DestroyDiagnosticsUtil)GetProcAddress(hinstLib, "DestroyDiagnosticsUtil");
pDiagnosticsUtil_WakeUpPrinter = (DiagnosticsUtil_WakeUpPrinter)GetProcAddress(hinstLib, "DiagnosticsUtil_WakeUpPrinter");
if ((NULL != pCreateDiagnosticsUtilW) && (NULL != pDiagnosticsUtil_WakeUpPrinter))
{
std::cout << "Getting Printer Name...n" << std::endl;
const char* printerStr = "HDP5000 Card Printer";
int bufferSize = MultiByteToWideChar(CP_UTF8, 0, printerStr, -1, NULL, 0);
wchar_t* pPrinterName = new wchar_t[bufferSize];
MultiByteToWideChar(CP_UTF8, 0, printerStr, -1, pPrinterName, bufferSize);
std::cout << "Done getting Printer Name...n" << std::endl;
pDiagnosticsUtil = (pCreateDiagnosticsUtilW)((LPWSTR)pPrinterName);
//PVOID pDiagnosticsUtil = pCreateDiagnosticsUtilW(pPrinterName);
std::cout << GetLastErrorAsString() << std::endl;
if (NULL != pDiagnosticsUtil)
{
pDiagnosticsUtil_WakeUpPrinter(pDiagnosticsUtil);
std::cout << GetLastErrorAsString() << std::endl;
pDestroyDiagnosticsUtilW(pDiagnosticsUtil);
delete[] pPrinterName;
}
else
{
delete[] pPrinterName;
std::cout << "Problem instantiating pDiagnostics!n" << std::endl;
}
}
FreeLibrary(hinstLib);
}
else
{
std::cout << "Problem loading FargoNativeAPI!n" << std::endl;
}
std::cout << "nDone calling Fargo WakeUp Command";
}
catch (...)
{
// catch any other errors (that we have no information about)
std::cerr << "Unknown failure occurred. Possible memory corruption" << std::endl;
}
return status;
};
New contributor
rbrennan10 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.