Control when someone tries to print - c#

Is it possible know when someone is printing a file in Windows using c# with any visual studio library?
I have no idea if its possible and where to start...
What I wanna to do is: everytime someone tries to print a file in Windows, my c# program execute and update some information in a database.

You might take a look at PrintSpooler
Here are some examples of using it:
PrintMonitor – A C# print spooler monitor
Monitor jobs in a printer queue (.NET)
You might also run it as Windows Service, so it is always running on background and starts when system starts.

Related

How do I programmatically set a a collection of default apps in Windows 10

Every time Windows 10 updates it resets a series of default apps to Microsoft defaults. I want my videos and music handled by VLC and my photos by Irfanview. The MS default will not even give me good previews. After manually resetting default apps a few dozen times I am willing to write an app that runs in the background and protects my defaults - I understand Microsoft makes this difficult - does anyone know how.
I tried the registry changes here http://winaero.com/blog/prevent-windows-10-from-resetting-your-default-apps/.
I tried Stop Resetting My Apps. I read this piece with a paragraph suggesting Microsoft will make this hard Windows 10 equivalent of LaunchAdvancedAssociationUI.
Does anyone have a solution - again I want something that can run in the background and set associations to my preferences not Microsoft's.
Although this post is over 5 years old, the SetUserFTA might help you.
See references here and here.
It worked for me to to programmatically set the default browser in Windows 10 and it should work for any other file types.
I wrapped it in a BAT file, which I scheduled via Task Scheduler and I can also execute on-demand. Make sure to run it with elevated (highest) permissions, from your user account.

Debugging by attaching a process for windows phone apps

I'm currently running VS2013 Update 3, I'm building an app and i;m trying to mimic the Rate My App that shows up rate message dialog in b/w specified intervals.
My problem is that i've made a setting using ApplicationData.current.loclasettings and it is an integer.
and i want to see the settings number being updated every time i close and run the app to ensure the logic is perfect.
but i'm unable to do it. Every time i deploy the app from vs it replace the original app and thus erasing all the settings that have been previously saved.
I've tried to use attach a process but it doesnt work on windowsphones.
Well after a bit of research and going through the documentation it is clear that there is no way you can attach a process to the app that is already running on the phone.
At least for me there was no other way because Microsoft kept the USB debugging thing a little bit undocumented or not documented at all.
So, who ever are looking forward to first launch the app on a connected windows phone and then start the the connect to a process and select the appropriate device for communication , story it is not possible, at least the build that i;m using doesn't support. may there might be a better solution in the future.

Continuously upload images on server using ssh

i develop one c# windows application for Continuously upload screen shot images.
I want to run 2 or 3 process parallel without hang any other process, currently i use system.timer.thread but not work properly so please give me suggestion which technique is best to Continuously running each process.

Windows Service Printing PDFs

Have the need to nightly startup a process that creates PDF based Reports (Financial Charts). A past developer produced a component that uses System.Drawing and System.Printing to create and save the reports to a directory as a PDF using Amyuni. Now we would like to use that component to produce PDF off hours for analysts to use the next day. The actual graphs are custom drawn using GDI+ with DrawLine, DrawString, etc. Using the PrintPageEventArgs Graphics property as the canvas for the drawing.
Using the component works just fine from a Windows Forms application works just fine. When using the component running under a user account (not LocalSystem) so service has access to printers doesnt fail with any exceptions, but no files are created.
I know that System.Drawing and System.Printing not really supported from Windows Service, but supported doesnt mean doesnt work. Just means MS wont help you through issues.
Any idea what we can do to get this to work? This is not a high volume process. Currently they do it with a command line program and the Windows Task Scheduler, but that requires the user to be left logged in.
UPDATE:
So I tried this as a .NET console application and started it with the Windows Task Scheduler and the same problem occurs. Run the console application from the desktop and it works. Run it from Task Scheduler it runs, but no files are created. I do have extensive logging going on an no exceptions are occurring and it sure looks like the process is creating the charts. They just arent showing up in the output directory. I setup the task to run under the same account that I am logged in as. The previous task that did work was a Visual Basic 6 solution not a .NET solution.
For future readers of this post, the issue described on this question was caused by licensing restrictions of Amyuni libraries on Windows Server operating systems (Amyuni Technologies provides several licensing models according to the applications being developed). For this particular case, new licensing information was provided after contacting Amyuni Support and the issue was resolved.
Disclaimer: I work for Amyuni Technologies.

How to communicate with a separate application from c#

I have an .exe that runs on my computer. How can I connect to it from c#?
For example notepad.exe is running. I would like to write in notepad from windows form app or console app form. How can I do that?
Two suggestions:
either start the process using Process.Start()
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx
or use SendKeys from Windows Script Host
http://msdn.microsoft.com/en-us/library/8c6yea83(VS.85).aspx
It depends on exactly what you want to do. Using SendKeys is the simplest solution but it's crude and limited in functionality. You can do more and better with SendMessage, but this will be harder to code.
Have a look at this tutorial. As far as I can tell, it does exactly what you are looking for. I realize it's in German, so just look at the source code.
Reading from another process in windows is problematic to say the least. We did some work on this a while ago and it involved hooking into the low-level Win32 API using assembly language. Essentially, it's really not pleasant and if you can avoid doing this you'll have a lot more hair on your head.
Using SendMessage would work if the application you are sending to understands the message you are trying to send to it. I suspect that you start to get into security problems with this on later Windows versions (Vista + Win7) and would have to run your application with elevated privileges.
Why do you want to do this?

Categories

Resources