==================================================================================== INDICATION SAMPLE ==================================================================================== The current directory contains source code demonstrating the indication feature of MIAPI. NOTE: Please see ..\ReadMe.txt (Section 2. PREPARATION) for instructions on how to create environment variables which will be used in this sample. ==================================================================================== INSTRUCTIONS ==================================================================================== There are multiple sections below that correspond to each of the sub-folders in this folder. The sections and folders are 1. Provider 2. NativeClient 3. ManagedClient 4. CIMCmdlet 1. Provider ------------------------------------------------------------------------------------ This directory contains the provider code, most of which are generated by Convert-MofToProvider.exe tool from SDK. Following shows you how to generate provider code, implement the provider, compile the provider, and how to deploy the provider to a Windows 8 or Windows Server 2012 machine. 1) Generate provider code skeleton Run the following command line from an elevated command prompt (cmd.exe) %SDKBINDIR%\convert-moftoprovider.exe -MofFile %MISAMPLEDIR%\sample.mof -ClassList MSFT_WindowsServiceStarted MSFT_WindowsServiceStopped -IncludePath %CIM2260DIR% %MISAMPLEDIR% -ExtraClass Cim_Error -OutPath %MISAMPLEDIR%\indication\provider\temp -SkipLocalize This command will: - use the MOF file called Sample.Mof that in the folder identified by %MISAMPLEDIR% - generate skeleton code for the 2 classes following -Classlist - use the CIM 2.26 schema located in the folder identified by %CIM2260DIR% - use MSFT_Qualifiers.MOF located in the folder identified by %MISAMPLEDIR% - include generated schema & types for the Cim_Error class - place all output in the folder identified by the -OutPath parameter - skip the generation of resource IDs used for localization (this is covered in another sample) Generated code can be found under %MISAMPLEDIR%\indication\provider\temp. Following lists the generated files, with notes for each file. GENERATED FILES --------------- NOTE: All .h files define class types and helper functions to manipulate instances of the class, such as set/clear the property value, construct, clone and destruct. CIM_Indication.h CIM_InstIndication.h CIM_InstModification.h MSFT_WindowsServiceStarted.h MSFT_WindowsServiceStopped.h WindowsService.h module.c Defines and implements entry function (MI_Main) of the provider. Implements function (Load) which will be called once the provider is being loaded. Implements function (UnLoad) which will be called once the provider is being unloaded. MSFT_WindowsServiceStarted.c Implements the requested methods of a indication class. MSFT_WindowsServiceStopped.c Implements the requested methods of a indication class. schema.c Includes full schema of all related classes. This file should not be modified. To change the schema, modify the original MOF (in this case sample.mof) and re-generate the code. WMIAdapter.c To enable this provider build based on MI API running with WMI, this file implements several adapter functions. Provider.DEF Defines list of exported APIs from this provider. OTHER FILES USED BY THIS SAMPLE ----------- WindowsService.c This is provided as part of the sample code, and was created to show the most efficient way of working with the generated code. The business logic for the elements in MSFT_WindowsServiceStopped.c and MSFT_WindowsServiceStarted.c are implemented in WindowsService.c. If the schema is extended or updated, a new version of MSFT_WindowsServiceStopped.c and MSFT_WindowsServiceStarted.c will need to be generated. By placing the business logic in a separate file, the work to align the updates is significantly reduced. WindowsService.h svcind.vcxproj Visual studio project file for the indication provider. 2) Implement & compile the provider See *.c file for the implementation, especially MSFT_WindowsServiceStarted.c and MSFT_WindowsServiceStopped.c files. Open %MISAMPLEDIR%\misample.sln file with visual studio 2012 and make sure following settings are correct, then you will be able to build. - Click menu Build->Configuration Manager, select desired Active solution platform, "x64" for example. - Right Click "svcind" project and select properties. - Goto 'Configuration Properties' -> Linker -> Input -> Additional Dependencies Make sure "mi.lib;%(AdditionalDependencies)" was added there. NOTE: If the target windows 8 is 32bit (x86), then you need to set Active solution platform as Win32. 3) Register provider. Once the project above is built, you will have created a new provider called svcind.DLL. Copy the compiled svcind.DLL to a Windows 8 or Windows Server 2012 machine, and invoke the following command line from elevated commandline prompt (cmd.exe): Register-CimProvider.exe -Namespace Root/Standardcimv2/sample -ProviderName indication -Path svcind.dll -verbose -ForceUpdate Once that completes, svcind.dll should be successfully registered into system. NOTE: 1) This provider depends on service.dll provider, which should be registered into same namespace Root/Standardcimv2/sample. Refer to ..\service\readme.txt for registration instructions. 2) Register-CimProvider.exe is shipped in Windows 8 and Windows Server 2012, in %windir%\system32. 2. NativeClient ------------------------------------------------------------------------------------ See ReadMe.txt for details. 3. ManagedClient ------------------------------------------------------------------------------------ See ReadMe.txt for details. 4. CIMCmdlet ------------------------------------------------------------------------------------ This directory contains a ps1 script file, which demonstrate how to use CimCmdlets to consume the data from the the indication provider. To run the script, just open powershell.exe, and paste content of the PS1 file to PowerShell console.