I have
int from_fd[2], to_fd[2];
BOOST_ASSERT(_pipe(from_fd, 256, O_TEXT) != -1);
to redirect standard input/output of a thread to a pipe. It works for a PC. Unfortunately, _pipe doesn't seem to be even defined for Windows Phone. The compiler reports the function can't be found. Is there any other alternative?
I'm trying to forward everything in standard output to a pipe that another thread in the process can read.
Windows RT do not support pipes. Use Windows sockets instead of pipes for IPC.
Related
I am trying to sandbox I/O with multiple composite windows and I need to pipe whole driver I/O of sandboxed application.
I know how to pipe stdout stdin stderr on Windows, but I want to Pipe all output input devices availible. In C/C++.
How do I list them?
Can I store the old device pipe end?
It is possible to list them by
DeviceIOControl in win32 API
or by
ioctl in unix-like OSes.
According to the openRTSP page you must "terminate it cleanly, by signalling it with SIGHUP or SIGUSR1". Those don't exist in Windows so is there a method already coded openRTSP for windows I can instigate, or is there a way to signal in windows?
The answers I have found are:
No, you cannot signal in Windows.
No, there is no alternative way coded in openRTSP. The windows build simply #ifdefs out the signalling code.
A named Mutex is probably the easiest way of coding up the same feature.
How do I know in a windows program if a process is running if I only know the exe file name ?
The process in question is TeamSpeak3 ts3client_win64.exe for 64 bit and ts3client_win32.exe for 32 bit.
I am using C++
Use the CreateToolhelp32Snapshot function to create a snapshot of the current process table, then use the Process32First and Process32Next functions to iterate the snapshot. You can get the name for each executable file by looking at the szExeName field of the PROCESSENTRY32 structure.
See the MSDN example for a sample of how to use these functions.
The advantage of this approach is that, unlike any EnumProcesses-based solution, it doesn't suffer from race conditions: with EnumProcesses it can happen that a process gets destroyed after you finished enumerating the processes but before you got around to opening the process (or reading our the process executable name).
You can use a combination of EnumProcesses, OpenProcess, and GetModuleFileNameEx (or alternatively, QueryFullProcessImageName for Vista or later). MSDN even has an example.
Windows NT has several APIs for enumerating processes.
EnumProcesses
ToolHelp
NtQuerySystemInformation (discouraged)
WMI's Win32_Process (works remotely)
There's getaddrinfo() for blocking host resolution, but is there a non blocking method?
I don't think there is such a thing but you can always wrap it in a thread and use a semaphore to signal completion.
Linux has getaddrinfo_a(). See the StackOverflow tag getaddrinfo-a, such as this question "How to use getaddrinfo_a to do async resolve with glibc". But I guess this isn't applicable for Windows.
There is a cross-platform library c-ares for asynchronous DNS requests, which says it runs on Windows. (I haven't tried it myself.)
From the MSDN page on GetAddrInfoEx the OVERLAPPED parameter says:
On Windows 7 and Windows Server 2008 R2 or earlier, this parameter is currently reserved and must be set to NULL since asynchronous operations are not supported.
This means you can only use the OVERLAPPED function in Windows 8 and newer. Unless steve can show otherwise that it works in older version of windows...
From Windows Vista and Windows Server 2008 you can use GetAddrInfoEx with an OVERLAPPED structure.
Once the hEvent event is set in the OVERLAPPED structure use GetAddrInfoExOverlappedResult.
Is there a simple way of redirecting serial port output to a file, that I can put into place on a test Windows desktop system without changing any code?
I'm trying to debug a problem in a serial receipt printer module and I don't have the real device handy today. I don't want to start making any changes to the code if I can help it, I just want to capture what is currently being output at the moment so that I can review it in a file.
It's Windows XP, if that makes any difference.
Another option is through command line:
type com1: >> data.log
Another option: Use putty and turn on logging.
A quick google led me to RS232 Data Logger - I haven't tried it, but if it does what it says on the tin it should be OK for you. Edit: it appears to be incoming, not outgoing. Might be worth a try though :-)
You could run the printer module in a VM. VMWare allows you to redirect serial ports to files and named pipes.
Similar to VMWare, Virtual PC (& Virtual Server) can also redirect a COM port to a text file and setup is very simple.
I think in the control pandel, printers, you can add manual printer and install dummay one
So you can printing to a file for example
If you are developer use Serial Port component from .NET or if you don't are a developer and only want get information to file use windows HyperTerminal
I don't know if you can redirect COM ports but you can use com0com for that kind of job.
For example, you can pair (COM1, COM2), so you can write to COM1 and read from COM2.