


ReturnValue = EnumPrinters(PRINTER_ENUM_LOCAL, NULL, 4, printerInfo, sizeof(PRINTER_INFO_4), &bytesNeeded, &bytesCopied ) So what you should really be doing is something like It means that the function is expecting to WRITE data to some variable of yours to deliver information you need. You can't just go around declaring variables which match the function prototype, you have to think about how those parameters are going to be used.ĭo you know what the annotation _Out_ even means?

> "A null reference was passed to the stub" Can someone help me understand what's wrong with this code? I have no idea what that is talking about, since I don't understand what it refers to when it says "stub". "A null reference was passed to the stub" My problem is EnumPrinters fails with error 1780 : I've written some code to create a temporary text file( I haven't gotten to the actual printing yet, so I'm leaving it empty) also. }I decided to try to make my own code for printing a text document on the local printer. If ( remove(FILE_NAME) ) perror("Deleting file") ReturnValue = EnumPrinters(PRINTER_ENUM_LOCAL, NULL, 4, printerInfo, sizeof(PRINTER_INFO_4), bytesNeeded, bytesCopied ) PrinterInfo = malloc(sizeof(PRINTER_INFO_4)) MessageBox(NULL, (LPCTSTR)lpDisplayBuf, TEXT("Error"), MB_OK) (lstrlen((LPCTSTR)lpMsgBuf) + lstrlen((LPCTSTR)lpszFunction) + 40) * sizeof(TCHAR)) LpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT,

MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), And thanks MS./* Retrieve the system error message for the last-error code */ LnResult = EnumPrinters(PRINTER_ENUM_ LOCAL + PRINTER_ENUM_CONNECTIONS, 0, 2, HBuffer = GlobalAlloc(GMEM_FIXED, nBufsize) PRIVATE hBuffer, nBufsize, cBuffer, nCount, cInfo INTEGER INTEGER INTEGER GetLastError IN kernel32ĭECLARE INTEGER GlobalAlloc IN kernel32 INTEGER wFlags, INTEGER dwBytes INTEGER Flags, INTEGER EnumName, INTEGER Level, We all run XP.ĭECLARE INTEGER EnumPrinters IN winspool.drv GetLastError() returns 0, so that is no help. It works fine on my PC, but returns 0 on 3 other machines. I am calling Win API function EnumPrinters() from a VFP9 program.
