Using printer from Racket - printing

How can I send a string to the printer from a Racket program? I tried to find examples on the internet but could not find it. The Racket documentation has these pages but how to send string to printer is not clear: https://docs.racket-lang.org/reference/printing.html https://docs.racket-lang.org/reference/Printer_Extension.html
Thanks for your comments/answers.

The documentation here suggests that you need to create a printer-dc% object and draw to that. When you are done, call the end-doc method to send a request to the OS to actually do the printing.

Related

How to access a previously extracted field in a chained Lua dissector?

I'm new to Lua and I'm trying to write a dissector that would decrypt an encrypted MQTT payload. Wireshark already has an MQTT dissector that extracts the payload, which at the moment looks like gibberish because it's encrypted. I'd like to access that payload object in a chained dissector in order to run the decryption function on it. I'm unsure whether I should be using a field extractor to pull it from the packet or if, because the existing MQTT dissector has already done that, there's some other better way to access it.
I'm not really sure whether this is possible so I haven't tried anything yet. Thanks in advance!
Yes, to get the data, you'd use the Field Extractor, something like:
my_msg = Field.new("mqtt.msg")
To decrypt the message, you will need to supply the encryption key, perhaps through a preference for your chained/post dissector, and then you'll also need to add decryption support. Luckily, there does exist luagcrypt, written by Peter Wu (aka Lekensteyn), which may suit your needs. Peter has even written a Wireshark Lua dissector for the WireGuard tunnel protocol where he makes use of luagcrypt and which may serve as a helpful place to start.

How do I get the PrinterIndex using the Printer Name using Delphi?

I need to assign a printer for each of three different printing functions, labels, receipts and "standard" (e.g. A4). I have identified all of the printers available using listbox1.assign(printer.printers) but there doesn't appear to be a way to use this to establish the printer's PrinterIndex. I want to store the printername and index value in a file so that I can use printer.printerindex to assign a printer to each type of print job without asking the user to choose a printer using a dialog.
Am I going about this the wrong way, and if so, could someone please tell me the right way to do it, please? I've not had to use the printers unit directly before.
Save the printer name in the file, not the index.
When you restart the program and read back the printer name. Then loop thru all printers to find which one has the saved name (It could have been removed or renamed) and use that printer.

Getting printer used by default by a process

I need to print documents in a specific order.
To do that,i use shellExecute api to print documents.
Some documents may be quicker to print , so i have to wait for the document to be in the spooler before calling another shellExecute.
For that, i use FindFirstPrinterChangeNotification, waitForSingleObject and FindNextPrinterChangeNotification.
It works fine.
But if the application started by shellExecute is already open, it's possible that it prints on another printer that the windows default printer. (if default printer has been changed )
I could watch all printers, but, i'd prefer to know wich printer uses the started process and watch this printer.
With shellExecuteEx, i can get a handle to the process started by this api.
So, is there a way to know the printer used by default by a process ?
So, is there a way to know the printer used by default by a process?
No there is not. Programs are entitled to use whatever logic they choose to determine their default printer. So in general, you've no way to ask a process which printer it will use, without having more specific knowledge of the process in question.

Delphi internet hook

I want write a program in Delphi to watch the internet connection, and if a certain response received (in response to request from a program), send request again encoded to another server, get a new encoded response, decode it, and pass it as response to the program who sent the main request. But I don't now how to hook internet connection. I want to use this program to pass through filter my country governments made using a private program to avoid blocking it. Is there any idea?
Thanks for your answer.
Magenta Systems released a free set of Delphi components that let you see the network traffic on your computer and examine the content. If you see the response you are looking for, your monitoring program can send a request to another server.
Off the top of my head, I'm not sure if it will let you alter the content of the original packet. If not, then Marcus' suggestion of using a proxy might suit you better.
You can either try to hook stuff at the Winsock level (there's plenty of examples for that around), but I suggest you go one level deeper and use a Layered Service provider (LSP).
I have used Komodia's redirector from http://www.komodia.com. Commercial, but well worth it.
See also this post
Is it possible to intercept dns queries using LSP/SPI?

Delphi - alternative solution for a global keyboard hook

sorry for this little bit strange title, didn't found a better one..
I've got the following situation:
I have a PC with an RFID reader connected via USB.
I now need a program which pops up when ab transponder was scanned the the RFID reader and shows the scanned value. (The reader just simulates keystrokes)
Problem: the value of the transponder is something like 0001230431, and I can't change it. (To prefix a hotkey combination or so)
So I have thought about using a global keyboard hook, check if three zeros where typed in, capture rest of data and when the 10 digits are complete, call the application through an automation object and show the number.
But I'm not very exalted about using a global keyboard hook. Many AV programs don't like them very much, they are not so easy to handle with Delphi and I guess that's not very resource-friendly for such a little task...
So I'm looking for an alternative solution...maybe somebody has an idea?
Big thx!
ben, you can use the RegisterRawInputDevices and GetRawInputData functions.
first you must use the RegisterRawInputDevices function to register the input device to monitor and then you can retrieves the data from the input device using the GetRawInputData function.
Check theses functions too
GetRawInputDeviceList retrieves the list of input devices attached to the system.
GetRawInputDeviceInfo retrieves information on a device.
Why not make sure the Delphi app with a text edit control has focus before the scan is done? Then the keystrokes will go straight into your Delphi app.

Resources