C++ (Unmanaged) Microsoft Visual Studio 2005

  1. Start Microsoft Visual Studio 2005 and select Create Project from the start page or File->New->Project.
  2. Select Visual C++ ATL project, enter a project name and click OK.
    screenshot
  3. Click Finish.
    screenshot
  4. Right click on the project and select Add->Class.
  5. Select ATL->ATL Simple Object and press Add.
    screenshot
  6. Enter a short name for your batch queue item creator object and press next.
    screenshot
  7. Select Free Threading Model and press finish.
    screenshot
  8. In the class view right click on your tester creator object and select Add->Implement Interface.
  9. Select TestScriptRunner 5.0 Type Library<5.0> in the Available type libraries, add IBatchQueueItemCreator interface to your class via the > button and press finish.
    screenshot
  10. In the project solution explorer right click on the project and select Add->Existing Item and add BatchQueueItem.h, BatchQueueItem.cpp, Clock.h and Clock.cpp from the Test Script Runner install directory (usually C:\Program Files\Ideal Systems Consultancy Ltd\Test Script Runner).
  11. Right click on the project and select properties, All Configurations C/C++ Configuration Properties, add the Test Script Runner install directory to the Additional Include Directories box and click OK.
    screenshot
  12. In the project class view right click on the project, select Add->Class then C++ Class and press Add.
    screenshot
  13. Enter the name of your batch queue item object and enter BatchQueueItem as the base class then press finish.
    screenshot
  14. Open the batch queue item object header file and add the code below before the class definition replacing DemoBatchQueueItem with the name of your tester class:-
         class DemoBatchQueueItem;
         typedef CComObject<DemoBatchQueueItem> CComObjectDemoBatchQueueItem;
        
  15. Also within the class add the method below:-
         virtual bool execute();
        
  16. Open the batch queue item object source file and add BatchQueueItem("<description>","<Version>")to the constructor initialisation list. In this case this will be BatchQueueItem("Demo Batch Queue Item","1.0")
  17. Next add the implementation of the execute function. This function can do whatever is required and should return true if successful and false otherwise. You can obtain the name of the file via the fileName method. In the demo case this method will read the file perform a sleep for the amount of seconds indicated in the first line as is given below (you will need to add the include statement #include <fstream> to the top of the file) :-
         bool DemoBatchQueueItem::execute()
         {
             std::ifstream in_file(fileName());
             if (!in_file.bad() && !in_file.fail())
             {
                 char line[255];
                 in_file.getline(line,255);
                 int sec = atoi(line);
                 Sleep(sec * 1000);
                 return true;
             }
             return false;
         }
        
  18. In your batch queue item creator header and implement the four functions get_Version, create, get_NumberOfFileTypes and get_FileType. Below is the demo implementation for these. Please note you can create multiple tester types from creator object and you need to add a #include statement to each batch queue item object.
         STDMETHOD(create)(unsigned long Index, IBatchQueueItem * * pVal)
         {
             if (0 != pVal)
             {
                 if (Index == 0)
                 {
                     CComObjectDemoBatchQueueItem *temp;
                     CComObjectDemoBatchQueueItem::CreateInstance(&temp);
                     temp->AddRef();
                     *pVal = temp;
                     return S_OK;
                 }
                 return E_INVALIDARG;
             }
             return E_POINTER;
         }
         STDMETHOD(get_NumberOfFileTypes)(unsigned long * pVal)
         {
             if (0 != pVal)
             {
                 *pVal = 1;
                 return S_OK;
             }
             return E_POINTER;
         }
         STDMETHOD(get_FileType)(unsigned long Index, BSTR *pVal)
         {
             if (0 != pVal)
             {
                 if (Index < 1)
                 {
                     *pVal = CComBSTR("bqdemo").Detach();
                     return S_OK;
                 }
                 return E_INVALIDARG;
             }
             return E_POINTER;
         }
         STDMETHOD(get_Version)(BSTR * pVal)
         {
             if (0 != pVal)
             {
                 *pVal = CComBSTR("1.0").Detach();
                 return S_OK;
             }
             return E_POINTER;
         }
        
  19. In the StdAfx.h file change _ATL_APARTMENT_THREADED to _ATL_FREE_THREADED
  20. Compile the code and then select the program identifier from the registry file for your tester creator and add this to the system via the Admin->Add Batch Item Creator command. The program identifier for the demo tester creator is:-
    DemoBatch_VC_2005.DemoBatchQueueItemCre
        
  21. You can now create a text file with the extension bqdemo and write the number of seconds in the first line then drag this file to a batch queue.

If you wish to debug you batch queue item plug-in run TestScriptRunnerGUI.exe and create a new batch queue. Add a file with the extension associated with your plug-in and then Attach to process batchqueuepluginrunner.exe. You should then be able to put a break point in your execute method.