monitor

How to obtain the correct physical size of the monitor?

给你一囗甜甜゛ 提交于 2019-11-26 22:17:04
问题 How can I get the size of the display in centimeters or inches? This code does not always works correctly: HDC hdc = CreateDC(_T("DISPLAY"),dd.DeviceName,NULL,NULL); int width = GetDeviceCaps(hdc, HORZSIZE); int height = GetDeviceCaps(hdc, VERTSIZE); ReleaseDC(0, hdc) Especially for multi-monitor configuration. Update: I need to get the size just for ordinary monitors, which have a constant physical size. 回答1: I found another way. The physical size of the monitor are stored in the EDID, and

How do you monitor file access and changes on a file server by user name?

℡╲_俬逩灬. 提交于 2019-11-26 21:53:40
问题 I was asked to find a way to monitor changes (modification, renaming, deletion, moving) of files in specific folders on the company's shared file server (simple windows shared directory). I wrote a simple app in C# that uses FileSystemWatcher to monitor these changes and notify a particular email address of them. What I'd like to know now is how to find out the name/IP of the user/computer who made these changes. Any ideas? As an alternative to writing my own software, are there any good

Monitor vs lock

折月煮酒 提交于 2019-11-26 21:32:38
When is it appropriate to use either the Monitor class or the lock keyword for thread safety in C#? EDIT: It seems from the answers so far that lock is short hand for a series of calls to the Monitor class. What exactly is the lock call short-hand for? Or more explicitly, class LockVsMonitor { private readonly object LockObject = new object(); public void DoThreadSafeSomethingWithLock(Action action) { lock (LockObject) { action.Invoke(); } } public void DoThreadSafeSomethingWithMonitor(Action action) { // What goes here ? } } Update Thank you all for your help : I have posted a another

What's a monitor in Java?

我怕爱的太早我们不能终老 提交于 2019-11-26 21:19:17
What's a monitor referred to in concurrent programming in Java? When I read that "every object has associated a monitor" what does it meaning? Is it a special object? A monitor is mechanism to control concurrent access to an object. This allows you to do: Thread 1: public void a() { synchronized(someObject) { // do something (1) } } Thread 2: public void b() { synchronized(someObject) { // do something else (2) } } This prevents Threads 1 and 2 accessing the monitored (synchronized) section at the same time. One will start, and monitor will prevent the other from accessing the region before

How do you turn on and off a monitor from within a Java application?

老子叫甜甜 提交于 2019-11-26 21:01:49
问题 How do you turn on and off a monitor from within a Java application? In case you're wondering why, this is a kiosk style application where it would be great to turn off the monitors at night. Yes you can do it within the screensaver settings of the machine, but it would be great to do it programatically and avoid having to configure it on each machine. 回答1: Assuming you deploy your Java Applications on Windows, you can use this WIN32API functions: // turn off monitor SendMessage(HWND

Lock (Monitor) internal implementation in .NET

左心房为你撑大大i 提交于 2019-11-26 18:53:31
For mastering of some technology you have to know how it's made at one abstraction level lower. In case of multithreading programming, it will be good to know about synchronization primitives. Here is the question, how implemented Lock (Monitor) in .NET? I'm intrested in such points: - does it utilize OS objects?; - does it require user mode or kernel mode?; - what is overhead for threads that are waiting for lock?; - in what cases threads queue that awaiting for the lock could be violated?. Updated: "If more than one thread contends the lock, they are queued on a “ready queue” and granted the

CPU temperature monitoring

天涯浪子 提交于 2019-11-26 17:39:02
问题 For a programming project I would like to access the temperature readings from my CPU and GPUs. I will be using C#. From various forums I get the impression that there is specific information and developer resources you need in order to access that information for various boards. I have a MSI NF750-G55 board. MSI's website does not have any of the information I am looking for. I tried their tech support and the rep I spoke with stated they do not have any such information. There must be a way

Launch an application and send it to second monitor?

旧街凉风 提交于 2019-11-26 17:34:01
Is there any way to start/lunch a program through Process in another screen? Someone asked that here but there was no answer. Note: it is not a form in my app, I'm asking about running an external program in another screen! Since the window is not yours, you can only move it by invoking the Windows API. You will have to do this: Launch the process. Use FindWindow to retrieve the handle to the window. If the window doesn’t exist yet, the process hasn’t created it yet; sleep for 500ms and then try again. (But don’t go into an infinite loop; stop if you can’t find the window after a reasonable

Registering change notification with Active Directory using C#

Deadly 提交于 2019-11-26 16:28:28
问题 This link http://msdn.microsoft.com/en-us/library/aa772153(VS.85).aspx says: You can register up to five notification requests on a single LDAP connection. You must have a dedicated thread that waits for the notifications and processes them quickly. When you call the ldap_search_ext function to register a notification request, the function returns a message identifier that identifies that request. You then use the ldap_result function to wait for change notifications. When a change occurs,

Is it ok to read a shared boolean flag without locking it when another thread may set it (at most once)?

落花浮王杯 提交于 2019-11-26 15:45:26
问题 I would like my thread to shut down more gracefully so I am trying to implement a simple signalling mechanism. I don't think I want a fully event-driven thread so I have a worker with a method to graceully stop it using a critical section Monitor (equivalent to a C# lock I believe): DrawingThread.h class DrawingThread { bool stopRequested; Runtime::Monitor CSMonitor; CPInfo *pPInfo; //More.. } DrawingThread.cpp void DrawingThread::Run() { if (!stopRequested) //Time consuming call#1 if (