For my project I need a way to get data regarding screens that are connected.
In specific, I need to identify whether a monitor is a laptop internal screen or an external screen, and get all the screen data.
I need to get this information both in c++ and C#.
I read about Win32_DesktopMonitor, about EnumDisplayDevices and about Screen Class.
I read also some related questions here:
Monitor ID and Serial Number
Find Number and resolution to all monitors
EnumDisplayDevices vs WMI Win32_DesktopMonitor, how to detect active monitors?
I havn't found an answer yet. Any Ideas?
To get the information whether monitor is internal you can use WMI class WmiMonitorConnectionParams from root\wmi namespace.
Code would need to create a CimSession by connecting to WMI either through DCOM or WinRM (with authentication as needed if enumerating remote computer monitors), then call EnumerateInstances(#"root\wmi", "WmiMonitorConnectionParams") on that session.
Resulting collection will contain InstanceName (string) and VideoOutputTechnology (UInt32).
You will need both for each monitor so you can match them with the other stuff you need.
If VideoOutputTechnology is 0xFFFFFFFF, then that's the Default Monitor entry and it can be ignored. If it is 0x80000000, then it is internal. Other types of connection are documented in d3dkmdt.h header file (online documentation at the moment of this writing does not provide correct values for the enum).
The most reliable way to get model, serial number, as well as year and week of manufacture is by reading and parsing the raw EDID block (by calling WmiGetMonitorRawEEdidV1Block).
I hope you can get by on your own from here.
What you can do is query the Windows WMI classes:
http://msdn.microsoft.com/en-us/library/aa394554(v=vs.85).aspx
Those classes allows the user to collect various information about the computer (hardware, os, ...)
I don't know if you'll find the properties you need, but it might be worth a look.
You're looking for this class:
http://msdn.microsoft.com/en-us/library/aa394122(v=vs.85).aspx
Related
I have to make a program which monitor usb ports and when an usb device is plugged (joypad, flash drives, mouse, ecc...) I get a unique identifier (a deviceid or something else would be good).
At first I tried with C# using the system.management classes and querying the cim_logicaldevice class each second to get the new device plugged.
Some device returned more rows with DeviceID, but this isn't a problem. The problem is that the memory occupied by the program (in task manager) grows up constantly.
This is the source code:
http://pastebin.com/dQv3cMQC
Is there a way to avoid the growing of the memory usege?
I have to do this program in C++ or C# and it has to be the most efficient possible (because it has to be opened forever).
I would recommend looking at the USBView sample in the WDK. If you are unfamiliar with this, simply run it - this tool walks the entire USB tree on the system and prints out information and descriptor listings for each device.
In your case, I'd start at the RefreshTree() function in this sample, you can then follow the code to see how it enumerates the host controllers, hubs and finally devices. For each device that you find you can look at the bInterfaceClass in the interface descriptors to find out what types of interfaces it is advertising.
The easiest way to get the source to this sample is to install the 7.1.0 WDK which is currently available here: http://www.microsoft.com/en-us/download/details.aspx?id=11800
Above is a screen shot I took in Windows PE environment while applying an image to a machine. As you can see I have filtered the results of Windows Sysinternals Process Monitor so that only ReadFile operations on the Win8 32-bit image by the Dism.exe process are shown.
I am in need of finding a way to access this same information using C/C#/C++ without the .NET framework (because supposedly the .NET framework doesn't exist in PE environment). I have searched, asked around, and searched again for Namespaces and Classes that would allow me to extract this information from the kernel without luck.
I am most interested in having the ability to access the value "Offset" that you can see in the image. This number is the location offset of the Read operation on the file and I need this value for the program I am required to make.
Does anybody know how I can achieve my goal? This is obviously possible to do in the PE environment because Process Monitor does it, so how can I do the same thing?
You might want to look at file mini-filters. Process Explorer basically installs one on the system when you start it for the first time. The mini-filter can be installed and started without the need for a reboot.
The mini-filter runs inside the kernel like any other device drivers and from there you can monitor any file activity (read, write, create, delete, close, execute, etc.)
You'd have to write this in C. You can also get info from the OSR distribution list.
Could anyone please give me any idea as to where to start my coding in order to get data from OPOS(Datalogic Magellan device) weighting and barcode scanning in C#?? For example, what library and what function I should be using for this case. I am clueless as I have already spent numerous of hours searching for an answer online. Not even came close online.
I don't know any api that I can use to get the weight and barcode for the usb device into my C# program.
I am currently using Datalogic scale. I tried the build-in windows reader but it didn't read in any data from the device.
First off, I used the Microsoft.PointOfService library which can directly create connection to most of the opos base machine. And make sure you have your Logical Device Name right! Very Very important. This is NOT any normal name you found in your regedit, it MUST be define manually by yourself inside the opos adk program that you installed along with the opos machine.
Then you can pass in the name as usual in your C# program.
For example: you set USB_Scale as your logical device name inside OPOS program
in C#
this.myDevice = explore.GetDevice("Scale", "USB_Scale");
Note: Make sure you set claim to 1000; It might not work if you didn't do so.
Also : this.myScale = ((Scale)explore.CreateInstance(myDevice)); <- this might help~
The rest is just straight forward.
I'm creating a postscript printer for windows 7 which will accept print jobs and forward them to real printers. It will be shared in the LAN and can receive print jobs from LAN computers. I want to find out from which computer a print job came from before forwarding them to a printer. How can I do this? Is the details available in the print job itself?
Thanks
Take a look at the GetJob and EnumJobs spooler api functions. They both return one of two structures, JOB_INFO_1 or JOB_INFO_2. Each structure contains a pMachineName field, which is the name of the machine that created the print job. You may find the following links from pinvoke.net useful.
http://www.pinvoke.net/default.aspx/Structures.JOB_INFO_1
http://www.pinvoke.net/default.aspx/winspool/EnumJobs.html
Alternatively, you may also want to look into using WMI and the Win32_PrintJob class. Specifically the HostPrintQueue property.
We are assigned to develop an application using C# that can transfer print jobs between printers. I have looked on the Windows API, and System.Printing namespace but I can't find a class or function that can do this. Is there a free library out there that is suitable for this? How will you do this using .Net or the Win32 API?
If nothing exists in the Win32 API, then there will be nothing in .NET.
Unless the printer drivers are identical then you may have problems because the printer jobs go through some processing by the driver before entering the queue.
Have you considered a single queue with multiple printers associated with it (this giving more capacity and redundancy in case of printer failure)?
Isn't this a problem of load-balancing/routing a particular job to the least busy printer?
I'm pretty sure you can just CopyFile a SPL file to a new printer port if it's the same driver. If you print in EMF, you may be able to go across different drivers.
The port names might be a bit tricky depending on how the printer(s) are attached. WinObj and the rules of dev naming will be handy for tracking it down.