monitor

Trying to open display device handle to change brightness on Windows XP using C++

瘦欲@ 提交于 2019-12-02 17:54:03
问题 I am trying to write a C++/WinAPI code to change a monitor brightness. The code must be compatible with Windows XP so I can't use APIs like SetMonitorBrightness. So I thought to try out IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS but I can't seem to even get a device handle. HANDLE hDevice = ::CreateFile(_T("\\\\.\\LCD"), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if(hDevice != INVALID_HANDLE_VALUE) { //Do work here ::CloseHandle(hDevice); } else {

Monitor vs Mutex

会有一股神秘感。 提交于 2019-12-02 17:32:15
I read that mutex is a semaphore with value 1 (binary semaphore) which is used for enforcing mutual exclusion. I read this link Semaphore vs. Monitors - what's the difference? which says that monitor helps in achieving mutual exclusion. Can anyone tell me the difference between mutex and monitor as both are actually doing the same thing Since you haven't specified which OS or language/library you are talking about, let me answer in a generic way. Conceptually they are the same. But usually they are implemented slightly differently Monitor Usually, the implementation of monitors is faster/light

Can anyone explain thread monitors and wait?

谁说我不能喝 提交于 2019-12-02 14:38:54
Someone at work just asked for the reasoning behind having to wrap a wait inside a synchronized. Honestly I can't see the reasoning. I understand what the javadocs say--that the thread needs to be the owner of the object's monitor, but why? What problems does it prevent? (And if it's actually necessary, why can't the wait method get the monitor itself?) I'm looking for a fairly in-depth why or maybe a reference to an article. I couldn't find one in a quick google. Oh, also, how does thread.sleep compare? edit: Great set of answers--I really wish I could select more than one because they all

Can a thread call wait() on two locks at once in Java (6)

南楼画角 提交于 2019-12-02 11:28:32
I've just been messing around with threads in Java to get my head around them (it seems like the best way to do so) and now understand what's going on with synchronize, wait() and notify(). I'm curious about whether there's a way to wait() on two resources at once. I think the following won't quite do what I'm thinking of ( edit : note that the usual while loops have been left out of this example to focus just on freeing up two resources ): synchronized(token1) { synchronized(token2) { token1.wait(); token2.wait(); //won't run until token1 is returned System.out.println("I got both tokens back

Trying to open display device handle to change brightness on Windows XP using C++

二次信任 提交于 2019-12-02 08:55:17
I am trying to write a C++/WinAPI code to change a monitor brightness. The code must be compatible with Windows XP so I can't use APIs like SetMonitorBrightness. So I thought to try out IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS but I can't seem to even get a device handle. HANDLE hDevice = ::CreateFile(_T("\\\\.\\LCD"), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if(hDevice != INVALID_HANDLE_VALUE) { //Do work here ::CloseHandle(hDevice); } else { nOSErr = ::GetLastError(); //Get code 2 } I tried various combinations of GENERIC_READ, GENERIC_WRITE

Python/PyQt4: How do you find the SIZE of a monitor (in inches)?

拟墨画扇 提交于 2019-12-01 21:16:12
I'm trying to find the horizontal width of a monitor in inches or cm (not pixels!) to make a small "ruler" program. DPI would work too. I'm using PyQt4. try using the QDesktopWidget's width() and height() to get the width and height respectively. Class reference at QDesktopWidget Class Reference , this will give you the screens size in pixels and then use QX11Info.appDpiX , this will give you the DPI in pixels per inch. Use both the above info to calculate the screen size in inches. PS: The width() returns the union width, so in case you have multiple screens, it will return union width of all

How can .NET threads be waiting on a syncblk which is not owned by any thread?

大城市里の小女人 提交于 2019-12-01 16:35:51
I have a crash dump from my app showing a bunch of threads waiting on a syncblk, and the syncblk shows that it has no owning thread. How is that possible? I'm trying to reproduce the symptom in a test app, and I can't figure out what could possibly happen to produce that result....having the owning thread exit or die without releasing the syncblk still shows up as owning the object, just the threadid is "XXX"....I've tested using fully managed graceful exit and hard thread termination via pinvoke....I tested a bunch of different combinations of waits without pulses, mismatched enters and exits

Folder changes monitor made in Visual Basic 2010 does not write changes correctly

柔情痞子 提交于 2019-12-01 13:48:05
I've made a program in Visual Basic 2010, that monitors and write down changes in a folder eg. when a file deletes, when a file renames, when a file creates and which files, but it's a problem. I've writed the code to make a new line when another change is made, when a change is made, it writes it down to a file named log.txt, but the log only looks like "File log.txt has been modified" because the program, when it write changes to the log, it changes the log.txt to write down the log, but the strange is, it deletes everything in the document and writes "File log..txt has been modified" even

Restart ASP.NET application when folder contents change

做~自己de王妃 提交于 2019-12-01 11:21:38
I'm writing a web application that will have "plugins". The plugins will be .DLL files which will export their functionality through predefined interfaces 'n stuff. All the .DLL files are in a folder called "Plugins", and the ASP.NET application loads them all upon startup (by using Assembly.LoadFrom). The problem is that when developing, these plugins will change fairly often (all the functionality is in the plugins, the website itself is just a skeleton). Thus, I need a way to automatically restart the application when the .DLL files change. How do I do that? IF the plugins directory is

Can several threads hold a lock on the same monitor in Java?

和自甴很熟 提交于 2019-12-01 06:53:04
Currently we are analyzing a tomcat thread dump. A single thread dump of all threads running at that same time on a tomcat contains the following lines: ... "soldOutJmsConsumerContainer-1" prio=10 tid=0x00007f8409c14800 nid=0x231 in Object.wait() [0x00007f8403a9f000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) at java.lang.Object.wait(Object.java:485) at com.tc.object.RemoteObjectManagerImpl.waitUntilRunning(RemoteObjectManagerImpl.java:150) at com.tc.object.RemoteObjectManagerImpl.basicRetrieve(RemoteObjectManagerImpl.java:216) - locked