winapi

c++ structures and constructures

ok so i nee help with this constructures struct balls { balls() { SetTimer(hWnd, balls.BALL_ID, 1, null); } int Ex; int Ey; UINT_PTR BALL_ID; }; well when i set the timer im having trouble with balls.BALL_ID. the compiler thinks that balls is structure like balls something. wel...

c++ structs and const

ok well i have structure struct balls { balls(UINT_PTR const &val) : BALL_ID(val){} int Ex; int Ey; const UINT_PTR BALL_ID; }; balls ball1(0x1); and i have a switch statement switch(wParam) { case ball1.BALL_ID: if(ball1.Ex<300) { ball1.Ex++; ...

How to Compare Two variable of HANDLE type

i have to variable of HANDLE type . first variable is a process HANDLE (with name hProcess) that have'nt PROCESS_QUERY_INFORMATION access right. second variable is a process HANDLE (with name hwndProcess) too that i opened via OpenProcess function and have PROCESS_QUERY_INFORMATION access right. i sure both process is a one. but when ...

How to call Windows API functions in JScript?

I would like to obtain the current process id in a JScript script. This id is returned by the Windows API GetCurrentProcessId (http://msdn.microsoft.com/en-us/library/ms683180.aspx) function. How do I call this function in JScript? This obviously doesn't work: var id = GetCurrentProcessId(); WScript.Echo("ProcessId is " + id); ...

how to create a blocking function

Hi all. I have a thread that needs to dispatch a message (a simulated mouse event that it sends using SendInput) as soon as it's generated. I want this to happen in a loop where there is no sleep; adding any sleep hurts performance as I basically want the events to go in to the event loop immediately once they have been generated. Of co...

Get file type from windows registry in c++

Hi, I am trying to display file type of given filename (based on extension) using AssocQueryKey() API function. The problem is thar return wrong HKEY value sometimes. For example the following function works correctly on win 7 ultimate x64, but fails for some extensions like ".mp3" on my win xp x86 machine (other extensions works though)...

How can I scan another process memory to find what follows a specific string?

I want to scan the entire heap of a currently running native application through another process. For example, I want to know what follows all the instances of the ASCII sequence "test" in this process memory (in this case I would scan for "test" and keep reading after it). I tried to google for more information but didn't find much: I...

Downloading a file in Delphi

A google search shows a few examples on how to download a file in Delphi but most are buggy and half of the time don't work in my experience. I'm looking for a simple robust solution which will let me download a single exe (for updating my app) and will hold the execution of the current update thread until the download is done or error...

Windows notification for change of the periodic time adjustment

Can I monitor changes to the System Time Adjustment (which is change by SetSystemTimeAdjustment())? I need to monitor such changes for a high-accuracy real-time spectrogram view. Note: I know that WM_TIMECHANGE is sent whenever the system time is changed. This is not what I'm asking for. ...

C++ double buffer and memory

Ok so my double buffer works fine but it seems that it use a lot of memory. i know that double buffer should store a copy of the ellipse I'm drawing than paint it on the screen but it after that it deletes the copy and makes new copy but it doesn't seem to delete it here is my code hdc=GetDC(hWnd); HDC memDC=CreateCompatibleDC(hdc); H...

Log every window activated in MS Windows using Python based on AHK example

I'm trying to rewrite the following autohotkey script in Python: Gui +LastFound DllCall( "RegisterShellHookWindow", UInt,WinExist() ) MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" ) OnMessage( MsgNum, "ShellMessage" ) LastActiveWindowID := WinActive("A") Return ; // End...

Input Box in an MFC CWinApp prgram?

I need an input box in a UI program that is already written derived from the CWinnApp class and using MFC. I see it is using message boxes but I don't see any examples of input boxes.... How do I do this? (Using Visual Studio 6.0 in C++) Thank You. ...

Change background color of another program from C++ program

I'm trying to change the background color of a program I did NOT write. Looking at it with Spy++ I can see that the main class is "ThunderRT6FormDC". One of its children has the class "ThunderRT6Frame". Inside ThunderRT6Frame there are a bunch of ThunderRT6CommandButtons. I want to change the background color behind the buttons. I trie...

AnimateWindow API transparency problem with RichTextBox

I'm using the AnimateWindow API to show or hide a Form with a slide animation. The problem is that if the Form contains a RichTextBox control, it doesn't display this control correctly. It's transparent and doesn't show any text. After the animation is complete, double clicking somewhere in the control will reveal lines of text. I've c...

How to truncate HWND title

I am creating a window which opens to a dynamic title. I would like to have the window's title truncate if the window is resized and there isn't room to show the full title. For example, I have HWND handle = GetHWND(); // gets me the correct handle std::wstring title = L"some fairly long window title"; SetWindowTextW(handle, title.c_s...

mfc directory picker?

I did see this to modify CFileDialog (http://support.microsoft.com/kb/105497) but it looks like a lot more than I need. I'm using the CFileDialog to pick files, is there a simple way to use it to just select a directory? Any other suggestions? (I also saw this but is for XP only? http://msdn.microsoft.com/en-us/library/aa16394...

Class(Child window )destructor not getting called

I have created a window which has a toolbar with some icons, and I launch one more window clicking on the available icon from the main window. First window is created using CreateWindowEx method. the one I click using an icon is created using dialog resource. So without closing dialog, I directly close the main window. I see that dialog...

Can I pass STL data structures to a Win32 message loop?

I have a multithreaded Windows application where one of the threads has a message pump in it. I need to send a message to that thread, passing information to it. However, one of the libraries I want to use in the worker thread requires std::string. Can I do something like the following: typedef struct tagCOMMAND { std::map<std::stri...

Threading in Windows using C++

Hi, In C++ how can you use threads to not block my receive functionality in case of Sockets? // Receive until the peer closes the connection do { iResult = recv(lhSocket, recvbuf, recvbuflen, 0); if ( iResult > 0 ) printf("Bytes received: %d\n", iResult); else if ( iResult == 0 ) printf("Connection closed\n...

how can i make a program run sillently? (without the console window appearing)

For example, in C#, you can make a program run without the black screen appearing...so I thought: since anything you can do with .NET you can also do with Win32, maybe there's a solution. Any ideas? ...