winapi

How do I subvert computer idle detection on Windows?

In order to detect user absence GetLastInputInfo() can be used. I want to make GetLastInputInfo() return that I've just used keyboard/mouse all the time - as I've been actively using the computer so that whoever relies on GetLastInputInfo() thinks I'm actively using the computer. Can I use any Windows API functions to achieve that? ...

problems with searching in files and directories .. windows programming

Hi I'm studying this book (Addison Wesley Windows System Programming 4th Edition) and I think its useless Im working on a searching code that support the recursive so it can go in deepth in files and directories the code is working ( I guess ) no syntax error but the output is not what I want the out put of the search is like: not f...

Need help identifying Windows UI control

Can anyone identify the control that is being used to create the accordion-style tab layout in this Windows dialog? http://code-industry.net/images/imageprinter_pro.png ...

How to append text to a text file in WinAPI?

Hi guys, Ive got an annoying problem, I cant append any text to the text file. Every time I open it for writing, I overwrite the data. I tried to move the file pointer to the end of the file, but no result (no writing to the file at all). Here is the code: INVOKE CreateFile, offset filePath, GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_AL...

Add newline to a text field (Win32)

I'm making a Notepad clone. Right now my text loads fine but where their are newline characters, they do not make newlines in the text field. I load it like this: void LoadText(HWND ctrl,HWND parent) { int leng; char buf[330000]; char FileBuffer[500]; memset(FileBuffer,0,500); FileBuffer[0] = '*'; FileBuffer[...

Get list of fonts (Win32)

I want to make a combo box with all of the computer's installed fonts enumerated in it. I'm not sure how this is done. Do I need to access the registry to get this? Thanks ...

Squigglly line under a word (Win32)

I want to implement basic spell checking in a Notepad clone project I'm doing. I want to underline misspelled words with a squiggly like like Word does. I think I need to use GDI and draw on the text field, but I'm not sure how to draw on controls. Thanks ...

Update Text Field after font change (Win32)

After I use setcontrolfont, the text of the text field does not update. The onnly way I fixed this is by removing then readding all text but this seems hackish. How can I do it properly? Thanks *its a function I made: void SetControlFont(HWND hand, int size, char* name) { HGDIOBJ hfDefault; hfDefault = (HGDIOBJ)CreateFontA(siz...

Read Text From Windows Form

I would like, if for no other reason that an academic exercise, to be able to read text written to a form on a Windows Application. The program appears to be written in non-.NET, but in .NET terms, I think you would describe the program as having a Form with a Label and I would like to read the text from that label. I believe I can see...

How to obtain the first cluster of the directory's data in FAT using C# (or at least C++) and Win32API?

So I have a FAT drive, lets say H: and a directory 'work' (full path 'H:\work'). I need to get the NUMBER of the first cluster of that directory. The number of the first cluster is 2-bytes value, that is stored in the 26th and 27th bytes of the folder enty (wich is 32 bytes). Lets say I am doing it with file, NOT a directory. I can use...

Debugging MinGW program with gdb on Windows, not terminating at assert failure

How do I set up gdb on window so that it does not allow a program with assertion failure to terminate? I intend to check the stack trace and variables in the program. For example, running this test.cpp program compiled with MinGW 'g++ -g test.cpp -o test' in gdb: #include <cassert> int main(int argc, char ** argv) { assert(1==2); retu...

Get specific process memory space

Hi, I have a pointer (void *) to a function and I want to know which process this function belongs to. I have no idea which way to go about it, but I think it's possible by using some form of VirtualQuery trickery. Any help would be appreciated. Thanks in advance, CLARIFICATION: By "belong to process" I mean what process the function ...

Handling Messages in Console Apps/DLLs in C++ Win32

I would like to have the ability to process Win32 messages in a console app and/or inside a standalone DLL. I have been able to do it in .NET with the following article and it works great in C# inside a console app and standalone DLL http://msdn.microsoft.com/en-us/magazine/cc163417.aspx Is there a way to do the equivalent with C/C++ W...

How do I "schedule an interrupt" on win32/intel architecture?

I'd like to figure out how to schedule a real ISR on normal win32 architecture (not Windows CE!) Is it possible? ...

Event to handle Open With (WinApi)

I cannot find how I'm supposed to handle file opening in my program. For example if the user does Open With ... myprogram.exe then how do I handle that and do something with it. which WM_Message is sent? Thanks *no I mean if you have sometext.txt and openwith Notepad.exe, it magically displays the text, so how can I know if someone used...

C equivalent to Perl "system()" or Python subprocess

How do I execute another program from within a C program in Windows 32 - in a similar way as Perl's system() function or Python's sub-process module - such as DEL, REG, or other cmd.exe programs? ...

When using DrawText, what does TextFormatFlags.Internal (a.k.a. DT_INTERNAL) do?

When using TextRenderer.DrawText(), what does setting the TextFormatFlags.Internal flag actually do? Equivalently, what does setting the DT_INTERNAL flag to Win32's DrawTextEx() function do? More to the point, when should I set that flag and when should I not set it? The documentation says: "Uses the system font to calculate text metr...

How to name variables which are structs

Hello, i often work on private projects using the WinApi, and as you might know, it has thousands of named and typedefed structs like MEMORY_BASIC_INFORMATION. I will stick to this one in my question, what still is preferred, or better when you want to name a variable of this type. Is there some kind of style guide for this case? For ...

How do Hex editors display data so quickly?

I'v created a Notepad-like application and if I load a 1MB file into the textbox, it takes about 1 minute. The Visual Studio Binary editor displays lines, Hex, and ascii versions in a fraction of a second. How do they get the data into the textbox so quickly? Thanks ...

WM_KEYDOWN confusion

I'm trying to get my application to do something when CTRL+S is pressed. I'm just not sure how the W and L params work for WM_KEYDOWN. MSDN has something about bit fields which i'm not sure about. How can I detect CTRL and S? Thanks What do I do if another control aside from hWnd has focus? ...