WMI provider sample code and customised provider fails to work with WmiPrvSe

AndreyV 0 Reputation points
2025-05-09T09:41:43.7933333+00:00

Hi

I'm not sure whether this is the right thread, however I discovered that creating the WMI provider could be a tricky Also, the sample code from Microsoft does not work.

https://learn.microsoft.com/en-us/windows/win32/wmisdk/supplying-data-to-wmi-by-writing-a-provider

I'm not sure what the exact reason is. WmiPrvSe loads the provider dll when the WMI client queries the class saved in the .mof file and compiled from Windows\system32\wbem. However, the request is never successful, and no single line of provider dll is run (WmiPrvSe appears to do nothing).

I'd appreciate any help or setup instructions it might have missed that I need to do on my Windows 10 machine.

Regards,

Andrey

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,766 questions
{count} votes

1 answer

Sort by: Most helpful
  1. RLWA32 49,051 Reputation points
    2025-05-09T11:55:34.2433333+00:00

    The wmi provider link seems discuss the sample at https://github.com/microsoft/Windows-classic-samples/tree/main/Samples/Win7Samples/sysmgmt/wmi/vc/instprov.

    After adapting the sample so that it would build with VS2022 I made one change to the MOF file --

    I added the following -

    #pragma autorecover
    #pragma namespace("\\\\.\\Root\\CIMV2")
    

    Then after running mofcomp and regsvr32 I was able to use wbemtest.exe to instantiate an instance of the class

    CreateInstance

    CreatedInstance

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.