Figure 1   RecycleBin.cpp

 //======================================================================
 // Matt Pietrek
 // Microsoft Systems Journal, December 1997
 // FILE: RecycleBin.CPP
 // To compile: CL </DUNICODE=1 /D_UNICODE=1> RecycleBin.CPP SHELL32.LIB
 //======================================================================
 #define WIN32_LEAN_AND_MEAN
 #define _WIN32_WINNT 0x500
 #include <windows.h>
 #include <shellapi.h>
 #include <stdio.h>
 #include <tchar.h>
 
 int main()
 {
     SHQUERYRBINFO shqbi = { sizeof(shqbi), -1, -1 };
     
     if ( S_OK != SHQueryRecycleBin( 0, &shqbi ) )
     {
         _tprintf( _T("Error!\n") );
         return 1;
     }
     
     _tprintf( _T("Items:%u  Bytes used:%u"), (DWORD)shqbi.i64NumItems,
              (DWORD)shqbi.i64Size );
 
     SHEmptyRecycleBin( 0, 0, SHERB_NOPROGRESSUI );
 
     return 0;
 }
 

Figure 5   WinInet Modem APIs

InternetGoOnline
Prompts the user for permission to initiate connection to a URL.
InternetDial
Initiates a connection to the Internet using a modem connection.
InternetAutodial
Automatically causes the modem to dial the default Internet connection.
InternetSetDialState
Sets the modem dialing state.
InternetHangUp
Instructs the modem to disconnect from the Internet.
InternetAutodialHangup
Disconnects an automatic dial-up connection.
InternetCheckConnection
Allows an application to check if a connection to the Internet can be established.
InternetGetConnectedState
Retrieves the connected state of the local system.


Figure 6   New WinInet URL Cache APIs

GetUrlCacheEntryInfoEx
Searches for the URL after translating any cached redirections that would be applied in offline mode by HttpSendRequest.
FindFirstUrlCacheEntryEx /
FindNextUrlCacheEntryEx
FindFirstUrlCacheContainer /
FindNextUrlCacheContainer

Starts a filtered enumeration of the cache.
CreateUrlCacheGroup
Generates cache group identifications.
SetUrlCacheEntryGroup
DeleteUrlCacheGroup
Adds entries to or removes entries from a cache group.


Figure 7   SHLWAPI String APIs


StrChr / StrChrI
StrCmpN / StrCmpNI
StrCSpn / StrCSpnI
StrDup
StrFormatByteSize
StrFromTimeInterval
StrIsIntlEqual
StrNCat
StrPBrk
StrRChr / StrRChrI
StrRStrI / StrSpn
StrStr / StrStrI
StrToInt / StrToIntEx
StrTrim
StrCatW
StrCmpW / StrCmpIW
StrCpyW / StrCpyNW
ChrCmpI

Figure 8   SHLWAPI Path APIs


PathAddBackslash
PathAddExtension
PathAppend
PathBuildRoot
PathCanonicalize
PathCombine
PathCompactPath
PathCompactPathEx
PathCommonPrefix
PathFileExists
PathFindExtension
PathFindFileName
PathFindNextComponent
PathFindOnPath
PathGetArgs
PathGetDriveNumber
PathIsDirectory
PathIsFileSpec
PathIsPrefix
PathIsRelative
PathIsRoot
PathIsSameRoot
PathIsUNC
PathIsUNCServer
PathIsUNCServerShare
PathIsContentType
PathIsURL
PathMakePretty
PathMatchSpec
PathParseIconLocation
PathQuoteSpaces
PathRelativePathTo
PathRemoveArgs
PathRemoveBackslash
PathRemoveBlanks
PathRemoveExtension
PathRemoveFileSpec
PathRenameExtension
PathSearchAndQualify
PathSetDlgItemPath
PathSkipRoot
PathStripPath
PathStripToRoot
PathUnquoteSpaces

Figure 9   IScheduledWorkItem Methods


CreateTrigger / DeleteTrigger
GetTriggerCount
GetTrigger / GetTriggerString
GetRunTimes / GetNextRunTime
GetIdleWait
Run / Terminate
EditWorkItem
GetMostRecentRunTime
GetStatus / GetExitCode
SetComment / GetComment
SetCreator / GetCreator
SetWorkItemData / GetWorkItemData
SetErrorRetryCount / GetErrorRetryCount
SetErrorRetryInterval GetErrorRetryInterval
SetFlags / GetFlags
SetAccountInformation / GetAccountInformation

Figure 10   ScheduledTasks.cpp


//=============================================================
// Matt Pietrek
// Microsoft Systems Journal, December 1997
// FILE: ScheduledTasks.CPP
// To compile: CL /DUNICODE=1 /D_UNICODE=1 ScheduledTasks.CPP \
//             mstask.lib ole32.lib
//=============================================================
#define WIN32_LEAN_AND_MEAN
#define _WIN32_WINNT 0x500
#include <windows.h>
#include <mstask.h>
#include <tchar.h>

//=========================================================================
// Preprocessor macro that combines a bunch of often used boilerplate code.
// Prints out the results of the preceding operation, and bails out via
// _leave if the operation failed.
//=========================================================================
#define HANDLE_RESULT_CODE( x, hr ) \
        if ( SUCCEEDED(hr) ) { _tprintf( _T("%s worked\n"), _T(#x) ); } \
        else { _tprintf( _T("%s failed %x\n"), _T(#x), hr ); _leave; }
        
int main()
{
    CoInitialize( 0 );

    ITaskScheduler * pITaskScheduler = 0;
    ITask * pITask = 0;
    ITaskTrigger * pITaskTrigger = 0;
        
    _try
    {
        HRESULT hr;


        //=====================================================================
        // Create the ITaskScheduler interface instance
        //=====================================================================
        hr = CoCreateInstance(  CLSID_CTaskScheduler,       // REFCLSID
                                0,                          // LPUNKNOWN outer
                                CLSCTX_SERVER,              // CLSCTX
                                IID_ITaskScheduler,
                                (LPVOID *)&pITaskScheduler );
        HANDLE_RESULT_CODE( "CoCreateInstance(CLSID_CTaskScheduler)", hr );
        
        LPWSTR ppwszComputer;
        
        //=====================================================================
        // Retrieve and print out the name of the target computer
        //=====================================================================
        pITaskScheduler->GetTargetComputer( &ppwszComputer );     
        HANDLE_RESULT_CODE( "pITaskScheduler->GetTargetComputer", hr );
        _tprintf( _T("Target computer: %s\n"), ppwszComputer );


        //=====================================================================
        // Free the string allocated by ::GetTargetComputer
        //=====================================================================
        CoTaskMemFree( ppwszComputer );

        
        //=====================================================================
        // Create the ITask interface instance
        //=====================================================================
        hr = pITaskScheduler->NewWorkItem(_T("MyHappyWorkItem"),
                                            CLSID_CTask,
                                            IID_ITask,
                                            (LPUNKNOWN *)&pITask );                                 
        HANDLE_RESULT_CODE( "pITaskScheduler->NewWorkItem", hr );


        //=====================================================================
        // Set the name of the program associated with the ITask
        //=====================================================================
        hr = pITask->SetApplicationName( _T("CALC.EXE") );
        HANDLE_RESULT_CODE( "pITask->SetApplicationName", hr );
        
        
        //=====================================================================
        // Create an ITaskTrigger interface associated with the ITask
        //=====================================================================
        WORD iNewTrigger;   
        hr = pITask->CreateTrigger( &iNewTrigger, &pITaskTrigger );     
        HANDLE_RESULT_CODE( "pITask->CreateTrigger", hr );

        TASK_TRIGGER trigger;


        //=====================================================================
        // Retrieve the default value for the task trigger
        //=====================================================================
        pITaskTrigger->GetTrigger( &trigger );
        HANDLE_RESULT_CODE( "pITaskTrigger->GetTrigger", hr );

        trigger.wStartMinute++;     // Bump the start time up by one minute
        
        //=====================================================================
        // Store new task trigger values
        //=====================================================================
        pITaskTrigger->SetTrigger( &trigger );
        HANDLE_RESULT_CODE( "pITaskTrigger->SetTrigger", hr );
            
        //=====================================================================
        // Display the user interface that allows the user to change task info
        //=====================================================================
        hr = pITask->EditWorkItem( 0, 0 );
        HANDLE_RESULT_CODE( "pITask->EditWorkItem", hr );
        
        //=====================================================================
        // Get rid of the task, so that our demo doesn't leave litter behind
        //=====================================================================
        pITaskScheduler->Delete( _T("MyHappyWorkItem") );
        HANDLE_RESULT_CODE( "pITaskScheduler->Delete", hr );
    }
    __finally
    {
        if ( pITaskTrigger )
            pITaskTrigger->Release();

        if ( pITask )
            pITask->Release();

        if ( pITaskScheduler )
            pITaskScheduler->Release();
                    
        CoUninitialize();
    }
    
    return 0;
}