winapi

Switching from Win32 to Windows Mobile 6: any tips?

I'm starting on a Windows Mobile project (no .NET Compact Framework - just native code). Having been a Win32 programmer (managed and native) for many years, I probably have some "desktop-isms" built in my brain that just don't translate well to the mobile world. Are there any tips you may want to share about typical pitfalls for someone...

Converting LPCWSTR with WideCharToMultiByte. Need help.

i have a function like this: BOOL WINAPI MyFunction(HDC hdc, LPCWSTR text, UINT cbCount){ char AnsiBuffer[255]; int written = WideCharToMultiByte(CP_ACP, 0, text, cbCount, AnsiBuffer , 0, NULL, NULL); if(written > -1) AnsiBuffer[written] = '\0'; if(written>0){ ofstream myfile; myfile.open ("C:\\example.txt", ios::app); myfile.writ...

change boost thread priority

Im trying to change the thread priority in boost but im having no luck. Im getting a bad handle error (type 6) from the GetLastError function. I though native_handle() returned the handle for the thread? Any one know how to do this? void baseThread::applyPriority(uint8 priority) { #ifdef WIN32 if (!m_pThread) return; BOO...

Computing BITMAPINFOHEADER biCompression value for monochrome BMP

Hi all, Hopefully someone has an answer, and it's not TOO complex. I'm working on a C++ dll (no C# or .Net, fully static DLL). Anyhow, its woring on buildin monochrome bitmaps. I have all of it working EXCEPT the resolution. I get the Device Context, Get Compatible Device Context, build bitmap, draw what I need to (as black/white), ...

Using GetSaveFileName. I specify OFN_EXPLORER flag, but always get old dialog appearance unless I avoid using both hook and template.

Using GetSaveFileName. I specify the OFN_EXPLORER flag, but I always get old dialog appearance unless I avoid using both hook and template. (lpfnHook and lpfnTemplate (and their respective "enable" flags) in OPENFILENAME structure) If I avoid using just one or the other, I still get the old dialog appearance. I also tried no templa...

Read file access/modification timestamp

What win32 API C functions can I use to read the modification/access/created dates of a file? ...

I want to know what functions are available from a Win32.DLL

I have a DLL file that has some helpful functions I want to call in my application. Unfortunately I don't have the documentation for it any longer. Is there any way I can discover what are the functions exported by the DLL and their method signature? Maybe there's a utility that lists the functions and their arguments. Know of any? ...

How might I retrieve the version number of a Windows EXE or DLL?

How to retrieve at runtime the version info stored in a Windows exe/dll? This info is manually set using a resource file. ...

Do you know of a Java library to access the native windows api?

Either with COM or JNI. ...

Finding and replacing string tokens in a file in C++ using win32 API

I'm trying to find a way to replace all instances of a string token in a file with another string. How can I do this in C++ with the win32 API? In other languages this is an easy thing to do, but in C++ I am just lost. EDIT: For some context, this is for a WiX custom action. So portability is not a main priority, just the most simpl...

Any limitations for custom cursors using CreateIconIndirect?

My Windows application creates custom cursors at run time by using the WIN API CreateIconIndirect() function. The size of the cursor is dynamic and may sometimes be much larger than average (the icon being wider than 300 pixels). This seems to cause problems when using the application via Remote Desktop (and other similar 3rd party pro...

Showing size grip in CDialog?

I have seen code which handles the drawing of this thing (DFCS_SCROLLSIZEGRIP), but surely there is a window style which I can apply to get it "for free". Right? ...

How to set the text on the "save" button in Windows' file dialog?

I'm trying to set the text on the "save" button of the Windows "Save file as..." dialog. I've set up the hook, received the message, found the button (nb. If I call "GetWindowText()" I see "&Save" so I know it's the right button). Next I changed the text using "SetWindowText()" (and called "GetWindowText()" to check it - the text is co...

Writing a COM object totally from scratch?

I just started a new job that involves lots of COM programming. I'm doing ok so far, by going on my COM fundamentals that I've picked up along my journey as a dev, but I'm the kind of guy that needs to know everything. And working with COM all day irks me since I don't know how this stuff works. Is there a simple walk through to cre...

Enumerating a List of systems Com Ports in Delphi

Objective: I would like to be able to list the available COM Ports on a system in Delphi. Homework: I have read this SO thread on enumerating the LPT ports of a system using the registry. I have also found that the COM ports are listed in the registry at HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM but found unanswered gesticulation...

How can I make a window in another process modal?

I have an application that calls some other utility application to set some settings for a particular device. That utility application is called using ShellExecuteEx. So as not to confuse the user, it would be better to made the window of the utility application modal to my main window. How does one do this? Things I've tried: WaitFo...

Win32 Debugging Macros

What is the standard macro used to write text to the output window in Win32 (outside MFC)? I am looking for something which the pre-processor conditionally excludes from the release build. (This might sound like SO sacrilege but I've merely forgotten this one and there was too much noise on Google. We are on the verge of handcrafting ou...

Get List of All Regional Setting Formats in .net

Hi Everyone, Within Control Panel -> Regional and Language Options, there is a Formats tab, with a drop down of all possible language formats. I wish to retrieve this list using VB.NET. Could anyone point in the direction of which Windows API call to use? Thanks ...

Are there special considerations for a windows service to send messages to user windows?

I have to write a Windows Service application (no GUI) that will monitor an event, and if it occurs will send a standard windows message to an application. The handle of the application will be given to the service by a DLL which is then unloaded, so a windows message is the way we wish to use. The question though is whether the service...

How to get width and height from CreateWindowEx() window? C++

I have made a window with CreateWindowEx() function, now how do i get the width and height from that window i created? This sounds very basic thing to do, but i just couldnt find any answer ;_; This is needed because the window height is created automatically depending on how the Windows wants to create it. Language C or C++ ...