Moving child windows of a window at one go!

Here is a function that moves all child windows of a window at one go! 🙂 [sourcecode language=’cpp’]void MoveChildWindows( HWND hParentWindow, const POINT& ptOffset ) {    // Parent window should be valid    if( !hParentWindow || !::IsWindow( hParentWindow ))    {       ASSERT( FALSE );       return;    }    // Get first child […]
Continue reading…

 

touch!!

Remember good old unix/linux command called touch, so simple but very useful, it changes the modified and last access time of a file. Ever felt the need for the same in windows, well I did sometime back. There is a function in imagehlp.dll which is called TouchFileTimes. This is how we use it… [sourcecode language=’cpp’]// […]
Continue reading…

 

Showing “Select Computer” dialog, with all network computers listed out!

Ever seen that “Select Computer” dialog coming up and did you wonder how to have all those computer names without writing much code. There is an undocumented exported api in “ntlanman.dll” called ServerBrowseDialogA0 which is used exactly for this purpose. [sourcecode language=’cpp’]int main() { // Some funky stuff     HMODULE hMod = LoadLibrary( “Kernel32.dll” );     […]
Continue reading…

 

Using sndPlaySound to play a wave file!

This is how we do it… [sourcecode language=’cpp’]// Include file #include “mmsystem.h” // Link to this library #pragma comment( lib, “winmm.lib” ) int main( int argc, char **argv ) {     // Will block till the whole file is played, use SND_ASYNC to play asynchronously     sndPlaySound( “c://windows//media//ding.wav”, SND_SYNC );     // Play for ever, should use […]
Continue reading…

 

How to resolve a shortcut!

Ever wondered how to resolve a shortcut! There is a hidden helper function if you are using MFC, it’s called AfxResolveShortcut. I customized it a bit, so that we can use it independently without MFC, and here is the finished product. 😉 [sourcecode language=’cpp’]BOOL ResolveShortcut( HWND hWnd_i,                       LPCTSTR lpctszFileIn_i,                       LPTSTR  lptszFileOut_o,                       const int nPathLength_i […]
Continue reading…

 

Watching out for registry key changes using RegNotifyChangeKeyValue!

We can watch out for changes on a key in the registry using the function RegNotifyChangeKeyValue. Here is a demo on how to do this. 🙂 [sourcecode language=’cpp’]// Helper function void RegWatchOut( HANDLE& hEvent ) {    const DWORD dwEventFilter = REG_NOTIFY_CHANGE_NAME |                                REG_NOTIFY_CHANGE_ATTRIBUTES |                                REG_NOTIFY_CHANGE_LAST_SET |                                REG_NOTIFY_CHANGE_SECURITY;    RegNotifyChangeKeyValue( HKEY_LOCAL_MACHINE,                             […]
Continue reading…

 

Change console application title!

It’s easy to change the title of a console application, just call SetConsoleTitle with the new title. Eg: [sourcecode language=’cpp’]int main( int argc, char** argv) {      SetConsoleTitle(“Nibu’s console”); return 0; }[/sourcecode] Well now the title changes, but you can see the old title for a moment before it changes to the new one (well […]
Continue reading…