I have code to detect the connection of USB Flash Drives as volumes. The code has been working very well for awhile, but recently a fellow engineer's machine started to fail and didn't work right again until it was restarted.
The project uses Qt 4.5.0, but that shouldn't be very relevant to this question.
I register for the notificati...
I was debugging a multi-threaded application and found the internal structure of CRITICAL_SECTION. I found data member LockSemaphore of CRITICAL_SECTION an interesting one.
It looks like LockSemaphore is an auto-reset event (not a semaphore as the name suggests) and operating system creates this event silently when first time a thread ...
I am trying to recreate an existing C Win32 DLL with a single, simple function. I have managed to do this using VS C++ 2008 Express, and my new DLL works on my Vista dev machine, and on the client's XP machine. However, it doesn't work on other sites. I have checked dependencies and my DLL requires MSVCR90D.dll and KERNEL32.dll, where...
I'm having an issue with using SHGetFileInfo on the public desktop and files in the public desktop. I'll focus on the actual desktop folder (CSIDL_COMMON_DESKTOPDIRECTORY or usually "C:\Users\Public\Desktop"). Also - I've started seeing this behavior only recently, but I can't pinpoint the exact change which made it faulty. The actual ca...
I'm developing a custom autocomplete control in pure WinApi, and the problem that I've encountered is that I don't know how to hide the popup window when clicked outside of the control (e.g. emulate the combobox dropdown behavior). How is it usually implemented? Should I use mouse capture? Thanks.
UPD: Tracking keyboard focus doesn't fi...
I have a function:
HANDLE snapshot=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
...
result=Process32First(snapshot,&pe);
while(result) {
if(!_stricmp(process_name,pe.szExeFile)) {
processes.push_back(pe.th32ProcessID);
}
result=Process32Next(snapshot,&pe);
}
for(dword_vector::iterator i=processes.begin(); i!=processes.e...
I need to interface with a program suite that uses named. Win32 Events (eg, CreateEvent() API) to communicate between running processes.
I'm able to do this with some very simple C code
h = CreateEvent(NULL, FALSE, FALSE, argv[1]);
if (h != INVALID_HANDLE_VALUE) SetEvent(h);
However, due to policy issues, I can't install custom...
I was trying some code to capture part of the screen using getPixel on Windows, with the device context being null (to capture screen instead of window), but it was really slow. It seems that GetDIBits() can be fast, but it seems a bit complcated... I wonder if there is a library that can put the whole region into an array, and pixel[x]...
I'm using a batch file to open a few new windows. Once they complete their processes, I have the /c set they quit. However, I'd like for my main batch process to wait for one window to finish before moving on, instead of doing everything at once.
For example, if my main batch file has:
@ECHO OFF
start "Win1" cmd.exe /c scomp -out ........
I usually see this when looking at Win32 gui code. My assumption is that it is a standard bitwise or, but I also occasionaly see it in C#, and it seems like there would be a better (well higher level) way to do the same thing there. Anyway, here's an example:
MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | M...
I use _fsopen(path, "r+", _SH_DENYRW) for opening a file in C any parameter for protection (_SH_...) cause the same issue.
When opening an empty file, errno is set to 22 (EINVAL), not so when the file isn't empty - then all is OK. What can I do?
...
I'm trying to list available interfaces using the WSAIoctl function. I have to pass in a buffer to hold the complete list. I want to get a count of the interfaces before I allocate memory to hold the interface details but if I pass in a NULL pointer the call just fails (I dont get a valid count returned). Any way to get this count befor ...
I have an application that connects via a DSN to an Oracle database.
If the initial attempt to connect fails, then I make sure their DSN exists. If it does not exist, then I create it using the SQLConfigDataSource command.
That command requires the driver name as one of its arguments. On my machine, I have the 11g driver, so the follo...
I am using MsgWaitForMultipleObjectsEx() for my message loop, and Shell_NotifyIcon to create tray icons.
Here's the deal: Whenever the tray icon sends messages to it's owner window, the window won't receive the messages right away, instead they will get queued until any other type of message arrives (WM_MOUSEMOVE, for example).
Seems l...
Hi, what's the best practise for registering window classes for a win32 program?
Do you register every class in the WinMain function or as they're required?
...
I am trying to open a process handle in C# using the OpenProcess function as follows:
IntPtr hProcess = OpenProcess(0x410, false, pid);
where pid is the process ID of the process I would like to open.
When called on a PID whose user is "NT AUTHORITY\SYSTEM" (on Vista x64), the above call fails, with an "Access Denied" error.
How do ...
I would like to kill and restart explorer.exe from my C++ application, how would I do this?
...
I'm trying to get the process handle of, say example.exe, so I can call TerminateProcess on it. How can I do this? Notice, it doesn't have a window so FindWindow won't work.
...
I'm trying to programmatically start explorer.exe but I'm not having any luck.
This is my code:
cout << pName << "died, lets restart it." << endl;
STARTUPINFO startupInfo = {0};
startupInfo.cb = sizeof(startupInfo);
PROCESS_INFORMATION processInformation;
if(CreateProcess(pName, NULL, NULL, NULL, false, NORMAL_PRIORITY_CLASS, NULL, N...
Hi, I am trying to implement as small a subset of GDI+ as possible in order to port an application (written in C++) from Windows to Linux. Right now I am having a problem to understand how Bitmap::LockBits is supposed to work.
According to MSDN, it has a signature like this:
Status LockBits(
const Rect *rect,
UINT flags,
...