Hi, gave up with this project a long while ago - never got any where with the Office products. I was using madCodeHook see http://www.madcodehook.com/madCodeHookDescription.htm[^] which worked for every application I tried except the Office suite ! The project as I said is now long forgotten and I don't write code anymore - retired due to ill health.
pgibson007700
Posts
-
Hook Print Dialog in Word -
FindNextPrinterChangeNotification - Invalid HandleSorry no never got it working, abandoned the project a year or so ago.
-
Hook Print Dialog in WordMike, thanks for that, I'll tackle the problem another way.:)
-
Hook Print Dialog in WordI am using a system wide hookapi DLL which hooks StartDocA, StartDocW, EndDoc, PrintDlgExA, PrintDlgExW the latter so I can obtain the number of copies, page range etc. My hook DLL works for NotePad, WordPad etc but the problem I have is Word (and I presume the other Office applications) does not appear to use PrintDlgA, PrintDlgW, or the Ex versions to display the Print dialog and hence I cannot obtain the number of copies, page range etc. Does anyone know which API Word is using to display the Print dialog ? I am using Visual Studio .NET 2003, Windows XP (with SP2) and Office XP. Thanks in advance :confused:
-
Hook Print Dialog in WordI am using a system wide hookapi DLL which hooks StartDocA, StartDocW, EndDoc, PrintDlgExA, PrintDlgExW the latter so I can obtain number of copies, page range etc. My hook DLL works for NotePad, WordPad etc but the problem I have is Word (and I presume the other Office applications) do not appear to use PrintDlgA, PrintDlgW, or the Ex versions to display their Print dialogs and hence I cannot obtain the number of copies, page range etc. Does anyone know which API Word is using to display the Print dialog ? Thanks in advance :confused:
-
How to hook windows'socket functions using SetWindowsHookEx functionYou could look at the following http://www.codeproject.com/dll/apihijack.asp[^] which has a simple example showing how to hook API's.
-
Printer port ipaddress [modified]The portname returned on our network for 'standard tcp/ip' always starts with IP_, so if this is returned strip of the IP_ and the rest is your IP address. Hope this helps.
-
At StartDoc obtain the current printer nameI'm trying to obtain when the user starts printing, by having a global hook for StartDoc, what is the name of the printer that is currently selected, any ideas on how to obtain this ? Using VC++ 6.0 and Windows XP.
-
How to use Tokenize() wid CStrings in VC6How about this little class http://www.codeproject.com/string/ctokenex.asp[^]
-
FindNextPrinterChangeNotification - Invalid Handlehere is my code, I have taken out some debug strings, but the printername is valid as are the values of the handles returned. The code has been taken from the Microsoft Printmon example with just a few changes as I am using this in a class, hence the use of 'this' // setup printer name strcpy (pPrinterName, this->m_PrinterName); // open Printer, if access denied return ZeroMemory (&pd, sizeof (pd)); pd.DesiredAccess = PRINTER_ACCESS_USE; if((nReturn = OpenPrinter (pPrinterName, &hPrinter, &pd)) == ERROR_ACCESS_DENIED) return FALSE; // initialize local copy of the printer queue data ZeroMemory (&Queue, sizeof(Queue)); Queue.Printer.hPrinter = hPrinter; GetQueue (&Queue); // prepare for notifications, we want when a job is added, check for an error hPrinterNotification = FindFirstPrinterChangeNotification (hPrinter, PRINTER_CHANGE_JOB, 0, &NotificationOptions); if (hPrinterNotification == INVALID_HANDLE_VALUE) return 0; Queue.Printer.hPrinterNotification = hPrinterNotification; // loop while we are stilling waiting on Notifications while (Queue.Printer.hPrinterNotification != INVALID_HANDLE_VALUE) { if (WaitForSingleObject (Queue.Printer.hPrinterNotification, INFINITE) == WAIT_OBJECT_0) { // get the changes and reset the notification if (!FindNextPrinterChangeNotification (Queue.Printer.hPrinterNotification, &dwWaitResult, &NotificationOptions, (void **)&pNotification)) { ErrorBox(GetLastError(), "FindNextPrinterChangeNotification ...failed\r\n"); } Note also that the Printmon example also fails at the FindNextPrinterChange call with an invalid handle when the printer is a network one, so the error is consistent.
-
FindNextPrinterChangeNotification - Invalid HandleUsing the tried and trusted ErrorBox method as follows void ErrorBox (DWORD dwError, LPCSTR lpString) { #define MAX_MSG_BUF_SIZE 512 char *msgBuf; DWORD cMsgLen; cMsgLen = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | 40, NULL, dwError, MAKELANGID(0, SUBLANG_ENGLISH_US), (LPTSTR) &msgBuf, MAX_MSG_BUF_SIZE, NULL); MessageBox( NULL, msgBuf, lpString, MB_OK ); LocalFree( msgBuf ); #undef MAX_MSG_BUF_SIZE it displays ... each and every time for a network printer ! The handle is invalid.
-
StartDoc not being called by wordI have an application that hooks startdoca, startdocw, enddoc, startpage and endpage api's, however when using Microsoft Word (winword.exe) startdoca/w does not get called, anyone know what other api is starting the printing process ? Using APISPY32 from Matt Pietrek I can see that startpage/endpage and enddoc are being called but no startdoca/w, what gives ? Notepad for example has a startdocw call why not winword anybody know ?
-
Reading INF fileI have a VC++ application where I need to read (and sometimes parse) the contents of various printer manufacturers INF files to populate a listbox to enable our users to select which printer to install. I am stuggling to find example code using the following setupapi calls SetupGetLineByIndex SetupGetStringField I have tried using the Profile api's also, but some INF's are better than others and using GetPrivateProfileSection doesn't always work successfully and involves rather messing string handling. Any help would be appreciated, many thanks in advance.
-
Right click on listview item display context menuI have not written any code yet to process the right click, all I want to do is what Printers and faxes does i.e displays menu with Open, Printing Preferences..., Properties etc, remember my list control with only contain a text item, which is the name of the printer. Therefore I can obtain server name etc and use OpenPrinter to obtain a handle etc.
-
Right click on listview item display context menuHi I have a listview control, created with single selection, the list contains the names of printers, port names etc. When I right click an item how can I display the context menu that is displayed when you right click a printer object in Printers and Faxes ? i.e the user sees the same menu to be able to delete/rename printer, click the properties item etc. I'm using Visual C++ 6.0 on Windows XP, and know how to obtain a handle and open the printer in question and use the PrinterProperties call, but I want to display the menu as you can in Printers and Faxes. Thanks in advance