winapi

Setting the width of a menu in the Windows API

I'm creating a custom control in wxWidgets that displays a menu as part of it, and currently working on the Windows side of things. wxWidgets doesn't have a way of setting the width of a menu. It just makes the window as wide as the longest string plus a few pixels on either side. In the API, there is a way to get the actual Windows A...

What is the MS Win32 API to know a folder is shortcuts?

In Vista and Windows 7, there are many folders are shortcuts, like "C:\Users\Administrator\Application Data", use FindFileFirst serial API can enumerate all files under the folder, however we can NOT open it in Windows Explorer, I will also get error while call CreateFile to open the folder or the file enumerated by FindFileFirst serial ...

Find the path of notepad.exe and mspaint.exe

What is the best way to find out where is notepad.exe and mspaint.exe that will work across various versions of Windows? Should I get the Windows directory via SHGetFolderPath(NULL, CSIDL_WINDOWS, NULL, SHGFP_TYPE_CURRENT, dir), and then traverse through all the subdirectories to look for the two files? (Assume that I am not interested...

How to force parent window to draw "under" children windows?

The environment is plain-old win32 under C/C++ without any fancy MFC or similar mumbo-jumbo. I have a window, which has several children and grandchildren. Some children are oddly-shaped icons, and I need them to have transparent background (oddly-shaped icons). Consider a this pseudo-structure: Parent1 Child1 (normal) Child2 (oddly-s...

The curious problem of the missing WM_NCLBUTTONUP message when a window isn't maximised

I've got a window that I handle WM_NCLBUTTONUP messages, in order to handle clicks on custom buttons in the caption bar. This works great when the window is maximised, but when it's not, the WM_NCLBUTTONUP message never arrives! I do get a WM_NCLBUTTONDOWN message though. Strangely WM_NCLBUTTONUP does arrive if I click on the right of th...

InternetReadFile Problem (error 87 - The parameter is incorrect)

Hello, I have a problem here with InternetReadFile, if I run the application in a computer without proxy, the app runs ok, but if I try to use with a computer using proxy, I receive an error 87 (The parameter is incorrect). Thats my code: conHandle = InternetOpen("Test", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); ... hFile = Inte...

How to send text to Notepad in C#/Win32?

I'm trying to use SendMessage to Notepad, so that I can insert written text without making Notepad the active window. I have done something like this in the past using SendText, but that required giving Notepad focus. Now, first I'm retrieving the Windows handle: Process[] processes = Process.GetProcessesByName("notepad"); Console.Wri...

How to write and send text to mIRC in C#/Win32?

In a previous question, I asked how to send text to Notepad. It helped me immensely. For part 2, here's a simplified version of the same applied mIRC: [DllImport("User32.dll", EntryPoint = "FindWindow")] public static extern IntPtr FindWindow(String lpClassName, String lpWindowName); [DllImport("user32.dll", EntryPoint = "FindWindowEx...

Api to turn on your computer

I'm Making a small on-line clock (both for fun and to learn a bit more of php and javascript) started it because i actualy need an alarm clock and this would be easier than buying one (don't ask) Now i wanted to know one thing, i know it's impossible to turn on/off you're computer from a browser, but a friend asked me if i could do him ...

Detecting when a CControlBar's docking state has changed

I'm using a CControlBar-derived class and I would like to detect when the docking state of the CControlBar has changed (i.e., docking from vertical to horizontal or when it goes into floating mode). Of course, I could handle WM_SIZE but it seems to be a waste of ressources doing the task every time a WM_SIZE message is fired instead of ...

Get icons for common file types

Hi I want to get the icons of common file types in my dll. I am using vc++. I only have the file extension and mime type of the file based on which I want to get the icon for the file. Can someone please tell me how I can do that? (The method available in vc++ needs the user to give the path of the file for which the icon is needed. I ...

Windows API and .net languages

People always advised me that if I am doing some application that should use some Windows APIs to do any process level job, I must use VC++ and not any other .net language. Is there any truth in that? Can everything that can be done using VC++ be done in other .net languages also? Are all the .net languages the same when their capabil...

Download and save any web page as Unicode, using Delphi 2009?

I wish to download a web page, which may be in any possible text encoding, and save it as UTF16LE. Assuming I can determine the text's encoding (by examining the HTTP header, HTML header, and/or BOM), how do I convert the text? I am using Delphi 2009. Unfortunately, the help files do not explain how to get from any encoding to a Unico...

Restore application from system tray

What is the best way to programmatically restore and give focus to a third-party application (say, GoogleTalk or Twhirl) running in the system tray? I am writing my utility in C#, but I obviously have no control over the third-party application. ...

modify an open file c++

Under Windows is there a way to modify a file/executable opened by another process using c++? ...

IntPtr, SafeHandle and HandleRef - Explained

Without pointing me to MSDN, could someone give a concise, clear explanation of the purpose of each of these and when to use them. (IntPtr, SafeHandle and HandleRef) ...

How should I deploy an MFC application?

I created an application in VS 2008 Express as an MFC app just to take advantage of the easy GUI creation. I might re-do this app in pure win32 since no other MFC classes are used (just a button and a text box, the button fires off the main program, all win32). My only question that determines whether I stay in MFC or port it over to pur...

IR Port API example C#/C++

Hi there, I'm looking for any code sample using the windows IR API. I want to make a little application, to control a windows based PC from an infrared remote control sending commands to a IR Port, and I'm having some some troubles in finding documentation. Do you know any opensource code, tutorial, or something to learn about this I...

Handle leaking in WinAPI CreateFile?

CreateFile allocates 2(!!) handles and CloseHandle closes only one handle when trying to get the low-level access to cd-rom device. OS Windows XP SP3, 5 of 7 tested computers works the same. When trying to access hdd drive letter CreateFiles works OK and allocate only one handle. Here is the sample code: HANDLE m_driveHandle = Create...

Best Way to Transfer Large Files in Windows

I often have to transfer large files >50GBs sometimes >100GBs between drives both internal and external during backups of our networks email servers. What is the best method of transferring these files? Command Line such as XCOPY? Possibly something robust enough to continue the transfer if interrupted due to time limits or network is...