winapi

Ending "recv()" loop when all information is Read using Winsock

Hey everyone, I am having an issue in my recv() loop for winsock. I am trying to terminate the loop when iResult==0, however, the loop only ends when the socket closes. It appears to be hanging at the very last recv() where iResult would equal 0. So any ideas on how to terminate the loop effectively? My ultimate goal (whether iResult ==...

Launch application

Hi all, I want to launch a application using win32 ... Plase let me know your ideas to achive the same ...

Can pipeline be used in sharing Dll in different process?

Hello all, Before I get into to my question,let me explain what I am exactly doing.I have a main Process say ProcessA,I have hooked ProcessA and also injected dll(say myDll.dll) into the process space of ProcessA.Now at one point ProcessA kicks on another process which is ProcessB.Both the process A and B are in totally diffe...

Create Process As User after loading user profile

Hi All, I have service that runs as system, i want to spawn new process in some user TS session with the user privileges. I'm calling LogonUser, LoadUserProfile, CreateEnvironmentBlock, CreateProcessAsUser and spwan the process in the user TS session. The process (cmd.exe) run in the user TS session, but when i'm trying to run GUI app...

Number of bytes read by synchronous ReadFile.

Assume I have 1Mb file, file pointer is at the beginning of the file. I call synchronous ReadFile: ReadFile(Handle, Buffer, 1024, Result, nil); the call is succesful, no error occured. Is it possible that Result value (number of bytes read) is less than 1024 (number of bytes to read)? I think that is impossible for disk files, I am n...

Send key stroke to window

I need to send a key stroke to some application. Now I use SendInput for that but it requires window to be foreground. I am going to use PostMessage/SendMessage for sending keystrokes but I heard there are some problems with them and they are not reliable. I would like to know what is wrong with PostMessage/SendMessage concerning KeyUp/K...

Find specific button with Ruby's WIN32API

I'm working on some scripted GUI test for a windows C# .net app. I'm using Ruby to drive the testing and my feet are officially wet in the realms of WIN32API - but I'm certainly not over-confident with it. As a mater of fact, I feel like I'm missing some fundamental understanding. At this point, the only way I know how to gain access ...

PostMessage: Access Denied

The application shall receive messages from all processes of the system. Messages are sent using PostMessage call, which returns an error (5, access denied). The code works correctly on Windows XP SP2, but on Windows 7 application receive messages from only itself, which it should be supposed to get message from every application. Rea...

Is it possible to modify a file without changing its hash value.

I need to edit some cfg files for an application, but the thing is the application wont start if I do since it must match. I dont have the sources of the application. I guess if the hash doesnt match the hash of the exe, it exits. Could you bypass this somehow? ...

Edit $(IncludePath) "macro" in Visual Studio 2010

Visual Studio 2010 ("Project Properties" dialog) I've installed Visual Studio 2010 Ultimate and it has apparently imported the default directories for my Win32 C++ includes and libraries. Every new Win32 C++ project I create automatically adds my old include/library directories which screws up my build. Here is the "Project Properties...

Datatype convertion problems

Hi all, some days ago i've posted a question for a win32 API stacktrace implementation with MSYS/Mingw: http://stackoverflow.com/questions/3318564/win32-api-stack-walk-with-mingw-msys The hint with the explicit loading of the dll was the correct solution. So i've restart the try to implement a stacktrace using the win32 CaptureStackBac...

python win32api in cygwin-1.75

Hello, when i run fabric-0.9.1 in cygwin, it say following error: $ fab test.py Traceback (most recent call last): File "/usr/bin/fab", line 8, in <module> load_entry_point('Fabric==0.9.1', 'console_scripts', 'fab')() File "/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 318, in load_ent...

Run a process as a synchronous operation from a Win32 application

I have an existing utility application, let's call it util.exe. It's a command-line tool which takes inputs from the command line, and creates a file on disk, let's say an image file I want to use this within another application, by running util.exe. However it needs to be synchronous so the file is known to exist when processing contin...

Show hidden window

I'm creating child console application using Process.Start method. Process is created with WindowStyle set to ProcessWindowStyle.Hidden. But then I need to SendInput to this window and try to show it using ShowWindow method. But ShowWindows has no effect. ...

How to achieve correct folder listing in C++

Hello. I have this code: #include "stdafx.h" #include <windows.h> #include <tchar.h> #include <stdio.h> void _tmain(int argc, TCHAR *argv[]) { WIN32_FIND_DATA FindFileData; HANDLE hFind; printf ("Target file is %s.\n", argv[1]); hFind = FindFirstFile(argv[1], &FindFileData); if (hFind == INVALID_HANDLE_VALUE) { ...

Migrating MFC (VC6) application to .NET 2008

I want very specific answer from the developers who did this and want to know how you resolved the problems you faced. We have very big MFC (VC6) 32 bit application existing for 10 years. Now we would like to migrate it to .NET unmanaged 64-bit application. Here we have some problems, our UI should not change, we may need some managed ...

python/win32: post a click event to a window?

I want to simulate a mouse click on a window, but I want to post the click event directly to the window (not by simulating a general mouse click using win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0)). What's the proper way to do it? I've tried the following, but it doesn't seem to have an effect: def MAKELONG(low, high): r...

how to find if a .exe is running in c++

how do you find if a exe is running (By name, i.e program.exe). Edit: Sorry im using it on windows ...

Detect laptop lid closure and opening

Is it possible to detect when a laptop's lid is open or closed? From what I've read, this isn't possible, but SO has helped me with the impossible before. The only thing I've found that might be in the right direction is an MSDN blog post about IOCTLs needed to report power buttons. Is it possible to "sniff" these as the OS calls them...

Is there a way to sleep unless a message is received?

I'm working in a service whose main loop looks like this: while (fServer.ServerState = ssStarted) and (Self.Terminated = false) do begin Self.ServiceThread.ProcessRequests(false); ProcessFiles; Sleep(3000); end; ProcessRequests is a lot like Application.ProcessMessages. I can't pass true to it because if I do then it bloc...