winapi

Platform ID in SERVER_INFO_101 Structure

Is there more precise documentation what PLATFORM_ID_DOS, PLATFORM_ID_OS2, PLATFORM_ID_NT, PLATFORM_ID_OSF, or PLATFORM_ID_VMS mean? The constants are defined in the lmcons.h file. Values can be got within the SERVER_INFO_100, SERVER_INFO_101, or SERVER_INFO_102 struct. Obviously PLATFORM_ID_NT means an NT-based platform. What's about...

What's the best way of getting the results of GetLastError() after a WinAPI call into a nice char* ?

I'm writing a DLL which a java program uses to call the WinAPI in various ways. I want to throw proper exceptions back to java but I need a nicely formated WinAPI error not just the int that get's returned from GetLastError(). I'm sure there's a nice way to do it. ...

Retrieving connection statistics from router via upnp in Windows

I've managed to write a small app which finds routers and does nat traversal via upnp by using the Windows API and this blog post here http://69.10.233.10/KB/IP/PortForward.aspx?display=PrintAll&fid=275054&df=90&mpp=25&noise=3&sort=Position&view=Quick&select=1800331 but now I'm trying to get some connection st...

Does Windows 7 render old programs' controls with GDI or the new DWM/WDDM?

In Windows XP the Win32 API renders the controls using GDI/GDI+. Now I'm on 7, so if I use the API's functions, will the rendering automatically be handled by the DWM/WDDM (so by DirectX)? or will it continue to render with GDI? Or likewise, will an old app written with WinAPI, be rendered with GDI also in Windows 7? Thank you in advan...

Are there any problems with this symlink traversal code for Windows?

In my efforts to resolve Python issue 1578269, I've been working on trying to resolve the target of a symlink in a robust way. I started by using GetFinalPathNameByHandle as recommended here on stackoverflow and by Microsoft, but it turns out that technique fails when the target is in use (such as with pagefile.sys). So, I've written a ...

Get Hardware Information for HWs that is not installed

I am pretty sure how to retrieve hardware information with WMI classes. but WMIs have a big limitation: They Just can get information for installed hardwares. I need to retrieve information about CPU (model,speed,etc..),Video Card, Sound Card, USB Ports, etc. I found a really good software (HWiNFO) that can do this even the drivers for ...

Casting string type with GetDlgItemText() for use as string buffer in C++

I am stumped by the behaviour of the following in my Win32 (ANSI) function: (Multi-Byte Character Set NOT UNICODE) void sOut( HWND hwnd, string sText ) // Add new text to EDIT Control { int len; string sBuf, sDisplay; len = GetWindowTextLength( GetDlgItem(hwnd, IDC_EDIT_RESULTS) ); if(len > 0) { // HERE: sBuf.resize(le...

Choosing between WPF, wxWidgets, Win32 API and MFC

Imagine you are on Windows 7 and you have to write a GUI for a GRAPHIC application, (like a terrain editor, mesh viewer ..) which involves a great use of DirectX and OpenGL (so written in native C++). If your goal is a multi-platform software then you should go for wxWidgets, but imagine you're doing a Windows' only app...what would your...

Out of memory (?) problem on Win32 (vs. Linux)

I have the following problem: A program run on a windows machine (32bit, 3.1Gb memory, both VC++2008 and mingw compiled code) fails with a bad_alloc exception thrown (after allocating around 1.2Gb; the exception is thrown when trying to allocate a vector of 9 million doubles, i.e. around 75Mb) with plenty of RAM still available (at lea...

Win32: "Save as" dialog file name hint

Some "Save as" dialogs provide a default file name - how is it done? I know how to create basic "Save as" dialog: OPENFILENAME, GetSaveFileName, and all that. But where should I put the string representing, say the file name of currently opened file? I thought it would come from .lpstrFile but this is not the case... Update: I was not ...

How to get text indent (tabs) from some text input?

For example, suppose I'm editing following text (\t is for tabs, it's not text) '\t\t\tSome text...' and my input keyboard position is right before 'S' (there is no selected text) and I want to get number of tabs before 'S' (in this case it's 3) So how to get that number of tabs using Win32 API? p.s. Maybe some function to get whole cu...

Can I mix C++ and C in a single project in Visual Studio?

I have a a Win32 DLL project in VS2008, it is written in a handful of C modules. Because I also want to be able to build outside VS2008, with no dependency on VS2008, I have produced a custom makefile, that does all the build and link steps. All this is set up just fine. Now I'd like to add a couple C++ modules to this DLL. I have mod...

Get current active line of text?

I want to get text from current active line (the line where the caret is) from any text editor that is currently in focus. My program that will get that text is working in background and doesn't have a GUI. How to get that line of text? ...

relaunch app when it ends or when it prints out certain text (stdout)

I have an app which acts almost like a daemon. Sometimes it quits on error and many times it prints an error msg then ask users to press any key to close. How can i relaunch the app when either case happens? I am more interested in the 2nd case. I can do this in c++, C# or python. The script is an old python that i dont want to change (...

Can Win32 popup menus respond to the scroll wheel?

Say I have a bog-standard Win32 popup menu, and it's taller than the screen. It sprouts an up arrow at the top and a down arrow at the bottom, so the user can scroll through its items. It's it possible at all for such a menu to response to Mouse Wheel scrolling? Scroll wheel events are sent to the focused control, which is not the menu,...

Is DbgHelp.dll built-in to Windows? Can I rely on it being there?

I use Jochen Kalmbach's StackWalker class from CodeProject, to produce a stacktrace when an exception occurs in my DLL. It relies on DbgHelp.dll Is DbgHelp.dll built-in to Windows Vista, WS2008, Windows 7? I know about The Debugging Tools for Windows from Microsoft, and I'm aware that DbgHelp.dll ships in that package. But I also f...

WM_SIZE with loword==hiword==-1 ?

Just tried some small graphics application of mine on Windows 7, and I'm getting a WM_SIZE event with loword==hiword== -1 -- can this be safely ignored, or does it have some special meaning? I never saw such sizes on XP/Vista, only with Windows 7. The docs don't tell much about what hiword/loword can be, so I wonder if -1 has some specia...

Trouble with detecting mouse movements in a TcxGrid when dragging files from Windows Explorer

I recently added a feature to a large application written in Delphi (version 2009) that allows the user to drag files from Windows explorer and drop them on a TcxGrid control. I achieved this via the common method of attaching my own window proc to the grid and intercepting the WM_DROPFILES message: originalGridWindowProc := cxGrid.Win...

How to evolve a COM interface?

COM is known to make backward-compatibility possible when releasing new components or applications. This is possible because interfaces in COM are stable i.e. they do not change. I tried hard to find a reference or book which deals with a descrition on how to evole a COM interface from version to version. The following are my requireme...

Strange behaviour of edit control background color when using WinXp common controls

Hi! I am having a strange problem ( well, at least i find it strange =) ). I am writing my own GUI library, which is a wrapper around windows api (and yes, i am aware of WTL and frameworks like MFC =) ). At the current stage i have incapsulated common controls in such manner: for example, Edit class consists of a simple window and an sta...