Adding a Schedule Using C++
The following is a C++ code fragment that adds a new schedule called "Extended Work Hours," which includes all hours on all days. This code was written as a Windows Console Application. To use this code:
In Visual C++, create a new Win32 Console Application.
Select the default empty project.
Create a new C++ source file in the workspace.
Paste the following code into the C++ source file, and build the project.
//Import the Forefront TMG Msfpccom.dll file so that Forefront TMG COM objects can be used. //Use the path to your Forefront TMG installation directory, or search for Msfpccom.idl. #import "c:\Program Files\Microsoft ISA Server\msfpccom.dll" #include <iostream.h> int main () { try { // Define variables. HRESULT hr; //Initialize the COM library on the current thread. hr = CoInitialize( NULL ); { // Define variables. FPCLib::IFPCPtr sipRoot; FPCLib::IFPCSchedulesPtr sipMyScheduleCol; FPCLib::IFPCSchedulePtr sipMySchedule; // Create the Forefront TMG root object. hr = sipRoot.CreateInstance("FPC.Root"); //Retrieve the schedules collection. sipMyScheduleCol = sipRoot->GetContainingArray()->RuleElements->Schedules; //Add the new schedule. sipMySchedule = sipMyScheduleCol->Add("Extended Work Hours"); //Set the schedule. sipMySchedule->Set(FPCLib::fpcALL_WEEK, FPCLib::fpcALL_DAY); //Save your changes. sipMyScheduleCol->Save(); } } catch (_com_error& e) { cout << "Error. HRESULT message is: \"" << e.ErrorMessage() << "\" (" << e.Error() << ")" << endl; if (e.ErrorInfo()) { cout << (char *)e.Description() << endl; } } CoUninitialize(); return 0; }
Run the application.
Related topics
Build date: 7/12/2010