winapi

How do I get the file HANDLE from the fopen FILE structure?

The fopen function returns a pointer to a FILE structure, which should be considered an opaque value, without dealing with its content or meaning. On Windows, the C runtime is a wrapper of the Windows API, and the fopen function relies on the CreateFile function. The CreateFile function return a HANDLE, which is used by other Windows AP...

SetWindowsHookEx seems not working for me in C# (WH_KEYBOARD_LL, global)

My application should perform some action whenever user pressed certain keys in windows. Calling SetWindowsHookEx with WH_KEYBOARD_LL option seems to be standard way to achieve this. However in my case something is clearly wrong and callback in not fired. Main method of my debugging console application: static void Main(string[] args...

Straight GDI Programming in C on Windows

Hello everyone, I have taken a recent interest in programming as efficiently as possible for Windows in straight C. I still want a GUI for some things, is the Windows API/GDI still the respectable way to go about this? I don't believe you can make regular calls for WPF, since it is largely a managed affair. Is GDI really un-accelerated ...

critical section problem in Windows 7

Why does the code sample below cause one thread to execute way more than another but a mutex does not? #include <windows.h> #include <conio.h> #include <process.h> #include <iostream> using namespace std; typedef struct _THREAD_INFO_ { COORD coord; // a structure containing x and y coordinates INT threadNumber; // eac...

How to get the fully qualified path name in C++

Hi, Is there a function that returns the fully qualified path name for any inputted file? I'm thinking of something like: LPCSTR path = "foo.bar" LPCSTR fullPath = FullyQualifiedPath(path); //fullPath now equals C:\path\to\foo.bar Thanks ...

How to clear a process command line?

I would like to clear the command line of my process from within. For example, when viewing my process in Task Manager/Process Explorer, the command line entry would be empty. I would like to do this within the currently running process rather than restarting the process if possible. ...

How to programmatically get the current audio level?

Basically, what I need is a way to tap into the current audio output and check the sound level, i.e. I need to be able to check whether there is something playing on the audio device or not. I do not need to check the volume setting, but the actual playing audio stream's sound level. Sorry, I was asking about how to do it in Windows, o...

Calling a function from a Win32 .lib project with /clr from a project that is a pure Win32 project, no clr

Hi All, I want to know how do I exactly call a function from ProjectA::ClassA::FuncA() that is a Win32 .lib with /clr from a ProjectB::ClassB::FuncB() that does not have clr support and is a pure Win32 project. Both these projects are under same solution. First, this is what I have tried: 1. Created the ProjectA with the .lib 2. Added t...

USe function from user32.dll in Qt4 application

Hi, i am unable to use the function MonitorFromPoint in my Qt application. I have the latest Qt SDL 2010.05 with mingw on Windows XP #include <QtCore/QCoreApplication> #include<windows.h> #include <winuser.h> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); POINT pt; MonitorFromPoint(pt,2); return a.ex...

Win32API: how to create a shortcut (.lnk file)

I'm a Java developer, so please excuse my ignorance. I want to create a shortcut to an executable, e.g., in the user's autostart or send-to folder (I don't want an installer to do that, because the installer usually is run by an administrator). What API (C preferred) I could use for that task (maybe using JNA)? Thanks in advance. ...

hooking another program's calls to winapi functions in vb.net

I have been trying to build a game bot in vb.net. One of the main problems is getting access to the text the game prints on the screen so I have been trying to hook the games calls to the windows api drawtext and textout functions. I have been hunting for examples of how to set up a hook in vb.net for a long time without any luck. I h...

Problem With ALT+SHIFT chaging language after "Using global keyboard hook (WH_KEYBOARD_LL) in WPF / C#."

Sorry for my weak English What I'm trying to do is to add the feature of press shortcut key to toggle show/hide program I've been searching how to do that and find http://stackoverflow.com/questions/1639331/using-global-keyboard-hook-wh-keyboard-ll-in-wpf-c --> http://gist.github.com/471698 which help me out. (Thank You everyone in the...

System Error 0x5: CreateFileMapping()

I wish to implement IPC using Named Shared Memory. To do this, one of the steps is getting a handle to a Mapping Memory Object, using CreateFileMapping(). I do it exactly as MSDN website reccommends: http://msdn.microsoft.com/en-us/library/aa366551(v=VS.85).aspx: hFileMappingHandle = CreateFileMapping ( INVALID_HANDLE_VA...

Debugging string from resource with assembly

Here is my issue. I'm trying to learn how to do debugging in assembly with OllyDBG. Usually, when a string is literally in the application, I can find something that points to it, however, this string is from the resource file (when doing WinAPI programming, a resource, .rc, is used). Therefore, given that it is in resource data, how can...

How can I get the current instance's executable file name from native win32 C++ app?

How can I get the current instance's file name & path from within my native win32 C++ application? For example; if my application was c:\projects\testapps\getapppath.exe it would be able to tell the path is c:\projects\testapps\getapppath.exe ...

Win32 alternative for the destructor in pthread_keycreate (when I cannot control dllmain)

In pthreads, you can associate a destructor function with each per-thread storage slot. When a thread dies, if the slot is non-0, the destructor is called. In a Win32 DLL, the DLLMain function, called at thread exit, can do the same thing. What can I do in code that lives in a purely static library? ...

Finding amount of RAM using C++..

How would i find out the amount of RAM and details about my system like CPU type, speed, amount of physical memory available. amount of stack and heap memory in RAM, number of processes running. Also how to determine if there is any way to determin how long it takes your computer to execute an instruction, fetch a word from memory (wit...

Issue with exceptions being caught by Win32 message dispatcher

This is kinda a very low-level type question, but maybe someone here has some insight... I'm having an issue where unhandled SEH exceptions (such as Access Violations) are seemingly being caught at the Win32 message dispatch level, rather than terminating the program. I found the following reference blog, which explains the problem, but...

C++ WINAPI: How to use SendMessage/PostMessage WM_KEYDOWN lparam

As an amateur to anything lower than VB/VBS (C++ WINAPI is a nightmare for someone of my experience) I have no idea how to go about constructing the long lParam for a simple KEYDOWN message in C++ and have probably spent more time looking for a decent explanation than is worth, would someone be able to describe exactly how to go about th...

Changing window background colour

In the winAPI, how do I change the window background colour? For example, wc.hbrBackground = ....; is for setting the window background initially, but how do I change it there after? Thanks. ...