Get data back from a windows Process to winform - c#

I'm new here and it's a first time that i ask for help to the community. I'm also new in C sharp but i try to manage and learn on the way.
I would like to have some help to understand how to write a Process for windows with wich i can communicate with my winform.
i made an winform application which permit me to retrive some data from Active directory and also some other data from computers on the network "using powerShell" and a AD class.
For some reasons i can't grab a correct information about ex: shared Printers, cose the PowerShell give me a output of the computer printers, not user printers. It was a simple exemple.
so i decide to write a Process wich i want to upload and install on a remote computer, till here i can manage that.
what i would like to understand and if you can show me a little exemple, it's how to add some functions to this process and get the output of this function back to my Winform.
as exemple:
1.in my Winform a make a remote call to the process and ask him to give me the list of all printers installed.
2. show the output in a lisbox for exemple.
I would like to tell you thank you in advance for you help

Related

how to show some info on secondary monitor in C# WPF?

i have some info that store in DB that should be displays some info about path destination and buses on secondary monitors in passenger terminal waiting rooms
now how can i doing this in c# wpf application?
does it need to design any form and than reflect to monitors or it could be done programmatically? or another way...
i am beginner in this scenario
You can split your application in two executables: The first one to insert data in the database. The second one to display info in secundary monitor, reading the information saved on the database.
The two application can run on same machine or separeted ones. If you can use a dedicated machine you can just run you second app on startup and then send computer output to secundary monitor.
If you need to run then on same machine you should have two videocard on that computer and use them as extended displays. The find a way to send specific app to specific screen. Hope it helps you.

Window CE 4.2 - Enumerating through the controls of a different running process

I have been charged with the task to send data from COM 1 to COM 2 in Windows CE 4.2. A running application takes data from COM 1 and displays it to the user in a form (textbox I assume). I then have to take that data and send it out COM 2. COM 1 is being used by the program displaying the data and I know of no way to hijack COM 1.
I figure trying to do a screen scrap would be the next step. Unfortunately this is compact framework and an old version at that and from a lot of research it seems managed code is out of the question . Many of the API functions I would use are not available; FindWindowEx for example.
Here is where I am at now. I have created two projects. One runs with a TextBox and some wording. A separate application runs and tries to read the text in that TextBox. I have been able to find the running process based off the name of the form using FindWindow API. Using code I have found on this site I have even been able to enumerate through the controls of the form. However my TextBox is never found and many of the controls that are found where never placed on the form by myself (listbox, button). I assume those are the form's initial controls.
Does anyone have any experience with this? Currently this is in C# but VB or Visual C++ will be fine. Even if you have any ideas on a third party application. BTW I am not given the option to upgrade to a higher version of compact framework.
Thank you.
An update I just found out about. It does not look like I only screen scrape only new data but instead have to screen scrape the entire screen and send it out COM2. Someone will scan a barcode and I will send out all screen data through COM2. The data may include a picture etc.
For a native C application I have one sceleton that enumerates all child windows and controls inside a dialog: http://code.google.com/p/rdp-auto-login/source/browse/trunk/rdp-auto-login/tscDialog.cpp. See ScanTSCWindow and the results found in the comment "TSC dialog elements".
I started with remote spy and looked thru the RDM window to find the CtrlID values. There is also a nice tool called zDump (http://www.hjgode.de/wp/2009/06/11/zdump-take-a-look-inside-windows-ce/) that runs on device and enables you to look at window elements.
The theory is that every element in Windows (either Mobile or desktop) is a window. Windows are accesible by there window handle. The handle is assign by the OS during CreateWindow/Ex. Inside dialogs, elements can be identified by there control ID (a resource value), the window class (ie "EDIT", "LISTBOX") and window text and internally by the window handle at creation.
The problem with Compact Framework apps is that they hide many of these basics and dialog (Form) elements can not be easily identified from another process.
As you say you are not able to capture COM1, what is, if you stop the application and then open COM1? As knonw, normally on one application can access a serial port at the same time. You can then read the serial data directly and do not need to access a foreign window.
There are also drivers that enable port mirroring or multiple access. Even for Windows CE based OS (ie http://www.virtual-serial-port.org/products/serial-splitter-mobile/).
If the application is a compact framework one you can take a look inside the code using .Net Reflector or similar .Net decompilers. I use that often to mimik or learn from other apps.
You say "I have been charged with the task to send data from COM 1 to COM 2 in Windows CE 4.2. A running application takes data from COM 1 and displays it to the user in a form (textbox I assume). I then have to take that data and send it out COM 2. COM 1 is being used by the program displaying the data and I know of no way to hijack COM 1." and if you do not start the other app you can write your own and do not need to parse the foreign app.
Possibly you can post the other app or more details of what it does what you can not do.
EDIT/UPDATE:
as we now know it is Intermec TE2000 (terminal emulation) the answer is to use the XMLRPC interface provided by TE2000. The interface is able to call back a function hosted by an xmlrpc server and send all screen content (text, fields and attributes) on screen changes. I have working c++ stl windowsce code for that.
If the device is connected via network, the xmlrpc server can even run on a PC.
As TE2000 does use native drwastring API you will not success in reading texts from the window. If you screen capture the window, you will have to do OCR on the image. XMLRPC does avoid all this.
UPDATE2:
I finished a class lib to get async screen updates using TE2000 xmlrpc: see https://github.com/hjgode/ITE_xml_rpc/tree/master/XmlRpcCS/XmlRpcCF
and http://community.intermec.com/t5/Thin-Client-Based-Development/Printing-CV60-Screen-Windows-CE-4-2/m-p/28663/highlight/false#M473

get status info Windows Media Player (stand-alone application)

I want to write an application which gets the status information about a running WMP thread, like playing/paused, shuffle mode on/off, repeat on/off, song title or media file path.
I was using the P/Invoke SendMessage-function to "simulate" a click on the play/pause/stop etc. buttons, but I'm unable read the values of labels/text boxes inside the WMP application with WM_GETTEXT.
I used Spy++ to get the handles of certain text fields - but they (obviously) change their handle after restarting the WMP.
Does somebody know a answer to this Problem?
It could be anything - P/Invoke or SendKeys - but not this AxWindowsMediaPlayer, because my application is a console app and I want the status information of the external process - not of my own.
Thanks
I will mark this thread as 'answered'.
I have solved this problem a few months ago, but lost the source code.
The aim of this application is to control the WMP via sshd or telnet.
You can download the binaries here if you want to:
WMP.rar (27 KB)
https://mega.co.nz/#!ug5DySRR!rQlI9OZZ8wYq7yAqaH-KYsmCl9LSaBjNdvqX0g_WDtI
The application is executed via console. You can see the commands by typing >wmp help

Get text of a textbox of an application from another application in C#

I want to read the value of a textbox. For example, "UserID" of TeamViewer from an application in C#. How can I do it?
Put in another way, I want to write an application that read the user id and password from TeamViewer.
You need to take help of user32.dll functions. Its an unsafe OS level library and allows you to access other running Applications on the platform. There is one more StackOverflow solution related to your problem at: How to read another windows from a different program and Get text from another application

Generating a file in the background based on user request

I have a C# web application (MVC1, .NET 3.5) with a function to generate reports. I was wondering if anyone has suggestions for how to implement the following scenario:
Logged in user clicks on the report button and goes on to browse other parts of the website OR simply logs off
Once the report is finished generating, it is e-mailed to the user
Main question being - how can I start a separate thread on the server that will accomplish this? If multithreading is not the way to go, please feel free to make other suggestions. Typical time to generate a report can be upwards of 10 minutes. Also, this functionality will rarely be used by more than one user at a time so I am imagining something along the route of "queueing up" a function and letting it execute in the background.
Thanks for all your help!
I suggest creating a Windows Service that polls the database for reports to generate, generates them and emails them. The specifics of the report are entered by the user on the website and the website simply stores that information in a database.
Have you looked at utilizing Microsoft Windows HPC Server 2008.. It fits your use case perfectly or you can stick to the routine and write a windows service that does this for you. But if you can afford it I would recommend jumping on the HPC bandwagon..
You can start reading about it here

Categories