I need to count amount of bytes sent and received from the network by various applications. First I thought about using LSP, but there is a lot of applications that do not use LSP at all (SMB for example). This is why I have written a small sniffer. This application works on IP level and collects data using recvfrom.
So I have address...
The Windows API DuplicateHandle()
http://msdn.microsoft.com/en-us/library/ms724251(VS.85).aspx
Requires the Object handle to be duplicated and a handle to both the original process AND the other process that you want to use the duplicated handle in.
I am assuming that if I have two UNRELATED processes, I could call DuplicateHandle() in...
I have a (set of) Word document(s) for which I'm trying to get various properties (number of pages, author, etc) using Win32::OLE in Perl:
print $MSWord->Documents->Open($name)->
BuiltInDocumentProperties->{"Number of pages"}->value . " \n";
This returns 4 pages. But the actual number of pages in the document is 9. The number of pages...
We have a legacy application written in C that uses WinAPI. We'd like to add a "Yes to All" button to a few of our dialog boxes. Unfortunately, the existing MessageBox function does not allow for custom buttons or button captions.
What's the best way to do so? Is there a slick hack to easily add a custom button? Or should we create ...
I have written a small function that will load multiple instances of an
executable using CreateProcessWithLogonW
the pseudo-code:
for ( i=0;i<100;i++)
{
sprintf(user,"user%i",i);
sprintf(pass,"pass%i",i);
if(NetUserGetInfo(user,pass)==NOT_FOUND) { NetUserAdd(user,pass); }
aaProcessCreateWithLogin("prog.exe",user,pass);
}
it wo...
I am trying to hook for example Notepad without sucess. Making a global hook seems to work fine.
Testing on XP SP2.
Edit: Amended code works now.
MyDLL code
#include <windows.h>
#include <iostream>
#include <stdio.h>
HINSTANCE hinst;
#pragma data_seg(".shared")
HHOOK hhk;
#pragma data_seg()
//#pragma comment(linker, "/SECTION:.share...
I wonder if and how it's possible to control the RS-232 handshaking lines directly from win32 (the old C-API).
I'd like to interface with an external piece of hardware, and two simple data-lines would be sufficient for my needs.
So - is there a API for win32 that lets me read and write the state of the four status lines? In normal se...
Hi I'm trying to read a registry value that gives me the path to firefox.exe.
This is stored under
HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox 3.0.10\bin
(the version number can be found somewhere else)
But I cant seem to get RegOpenKeyEx to return ERROR_SUCCESS for anything under
HKEY_LOCAL_MACHINE
so this test fails:
if...
I'm just starting my first C++ project. I'm using Visual Studio 2008. It's a single-form Windows application that accesses a couple of databases and initiates a WebSphere MQ transaction. I basically understand the differences among ATL, MFC, Win32 (I'm a little hazy on that one actually) and CLR, but I'm at a loss as to how I should choo...
I've got this code in my socket class:
bool GSocket::Listen(int Port)
{
d->Socket = socket(AF_INET, SOCK_STREAM, 0);
if (d->Socket >= 0)
{
sockaddr Addr;
sockaddr_in *a = (sockaddr_in*) &Addr;
ZeroObj(Addr);
a->sin_family = AF_INET;
a->sin_port = htons(Port);
a->sin_addr.OsAddr = INADDR_ANY;
if (bind(d->Socket, &Addr, ...
I know how to get the user that last modified a file, but does Windows track the process that made the modification as well? If so, is there an API for looking that up?
...
I'm playing around with retrieving the MAC address from the NIC - there are a variety of ways to get it, this article covers the most common:
http://www.codeguru.com/Cpp/I-N/network/networkinformation/article.php/c5451
I'm currently using the GetAdaptersInfo method, which seems the most bulletproof, but if the MAC address has been set ...
I'm trying to clear out the WinInet cache using Win32 API - by invalidating the cache entries, or deleting them (doesn't matter). I can't find any way to do this for the whole cache (other than iterating over each entry - example in C#, another in VB) - is this even possible?
...
I'm attempting to compile a screensaver using Visual C++ 2008 Express Edition SP1 on Windows XP. I get a runtime error: "The procedure entry point ChangeWindowMessageFilter() could not be located in the dynamic link library USER32.dll." As far as I can tell, this is because Microsoft botched the scrnsave.lib library included in VS 2008 t...
I have a scenario where I need to put together a script to add an entry to the following registry key for the current user:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\LastVisitedMRU\
I am trying to find out the maximum number of values allowed in this key so that I can have my script tack another one...
The target app is written in Delphi (win32 not .NET) and is closed-source.
The action I want to invoke is called Copy, but there is no obvious keyboard shortcut. (Ctrl+Insert does the wrong thing and Ctrl+C does nothing)
I can find my target HWND and persuade it to open the context menu (it responds to WM_RBUTTONDOWN/UP not WM_CONTEXTM...
I am trying to completely disable the letter 'a' on the keyboard using lowlevel keyboard hook. The problem is that when i return 0 from keyboardproc the key is not disabled but when i return 1 it gets disabled. I thought that returning from keyboardproc without calling
CallNextHookEx blocks the message. Is there any difference between re...
As far as I've been able to find out, Windows doesn't offer an API function to tell what application has registered a global hotkey (via RegisterHotkey). I can only find out that a hotkey is registered if RegisterHotkey returns false, but not who "owns" the hotkey.
In the absence of a direct API, could there be a roundabout way? Windows...
If I have a CImageList object (a simple wrapper around a HIMAGELIST), and I call:
m_pImageList->Replace(...);
http://msdn.microsoft.com/en-us/library/k10cwcdb.aspx
Who is responsible for clearing up the memory? Does the image list create a copy of any bitmap I pass in (i.e. can I create a CBitmap object on the stack then pass the a...
I followed this tutorial (there's a bit more than what's listed here because in my code I get a window via mouse click) for grabbing a window as a bitmap and then rendering that bitmap in a different window.
My question:
When that window is minimized or hidden (SW_HIDE) my screen capture doesn't work, so is it possible to capture a w...