Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem on a sample code in "Windows SDK" (COM interface)?

Problem on a sample code in "Windows SDK" (COM interface)?

Scheduled Pinned Locked Moved C / C++ / MFC
helpcomsecuritycryptographytutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bahareh655
    wrote on last edited by
    #1

    Hi all I've built a sample code named "enrollCustomCMC" in Windows SDK at "Microsoft SDKs\Windows\v6.1\Samples\Security\X509 Certificate Enrollment\VC" directory, but when the ".exe" file is built and I use it with the "Command Prompt", I see error in first "CoCreateInstance" function as "REGDB_E_CLASSNOTREG" that means: "Class not registered"! I couldn't find the reason even with debugging! The code is written using COM interface, here's the code: #include #include #include #include #include #include "enrollCommon.h" void Usage() { wprintf(L"Usage:\n"); wprintf(L"enrollCustomCMC \n"); wprintf(L"Example: enrollCustomCMC Name Value "); wprintf(L"www.adatum.com 1.3.6.1.5.5.7.3.1\n"); } HRESULT __cdecl wmain(__in int argc, __in_ecount(argc) wchar_t *argv[]) { HRESULT hr = S_OK; bool fCoInit = false; ICertRequest2* pCertRequest2 = NULL; ICertConfig* pCertConfig = NULL; IX509Enrollment* pEnroll = NULL; IX509CertificateRequest* pRequest = NULL; IX509CertificateRequestPkcs10* pPkcs10 = NULL; IX509CertificateRequestCmc* pCmc = NULL; IX509Extensions* pExtensions = NULL; IX509Extension* pExtension1 = NULL; IX509Extension* pExtension2 = NULL; IX509ExtensionEnhancedKeyUsage* pExtensionEKU = NULL; IX509ExtensionAlternativeNames* pExtensionSAN = NULL; IObjectId *pEKUObjectId = NULL; IObjectId *pSANObjectId = NULL; IObjectIds *pEKUObjectIds = NULL; IObjectIds *pSANObjectIds = NULL; IAlternativeName * anDnsName = NULL; IAlternativeNames * pAlternativeNames = NULL; IX509NameValuePair *pPair = NULL; IX509NameValuePairs *pPairs = NULL; PCWSTR pwszName; PCWSTR pwszValue; PCWSTR pwszDnsName; PCWSTR pwszEKU; BSTR strCAConfig = NULL; BSTR strDnsName = NULL; BSTR strName = NULL; BSTR strValue = NULL; BSTR strEKU = NULL; BSTR strRequest = NULL; BSTR strCert = NULL; BSTR strDisposition = NULL; LONG pDisposition = 0; // Process command line arguments if (argc != 5) { Usage(); hr = E_INVALIDARG; _JumpError(hr, error, "invalid arg"); } else { pwszName = argv[1]; pwszValue = argv[2]; pwszDnsName = argv[3]; pwszEKU = argv[4]; } // CoInitializeEx hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); _JumpIfError(hr, error, "CoInitializeEx");

    _ M 2 Replies Last reply
    0
    • B bahareh655

      Hi all I've built a sample code named "enrollCustomCMC" in Windows SDK at "Microsoft SDKs\Windows\v6.1\Samples\Security\X509 Certificate Enrollment\VC" directory, but when the ".exe" file is built and I use it with the "Command Prompt", I see error in first "CoCreateInstance" function as "REGDB_E_CLASSNOTREG" that means: "Class not registered"! I couldn't find the reason even with debugging! The code is written using COM interface, here's the code: #include #include #include #include #include #include "enrollCommon.h" void Usage() { wprintf(L"Usage:\n"); wprintf(L"enrollCustomCMC \n"); wprintf(L"Example: enrollCustomCMC Name Value "); wprintf(L"www.adatum.com 1.3.6.1.5.5.7.3.1\n"); } HRESULT __cdecl wmain(__in int argc, __in_ecount(argc) wchar_t *argv[]) { HRESULT hr = S_OK; bool fCoInit = false; ICertRequest2* pCertRequest2 = NULL; ICertConfig* pCertConfig = NULL; IX509Enrollment* pEnroll = NULL; IX509CertificateRequest* pRequest = NULL; IX509CertificateRequestPkcs10* pPkcs10 = NULL; IX509CertificateRequestCmc* pCmc = NULL; IX509Extensions* pExtensions = NULL; IX509Extension* pExtension1 = NULL; IX509Extension* pExtension2 = NULL; IX509ExtensionEnhancedKeyUsage* pExtensionEKU = NULL; IX509ExtensionAlternativeNames* pExtensionSAN = NULL; IObjectId *pEKUObjectId = NULL; IObjectId *pSANObjectId = NULL; IObjectIds *pEKUObjectIds = NULL; IObjectIds *pSANObjectIds = NULL; IAlternativeName * anDnsName = NULL; IAlternativeNames * pAlternativeNames = NULL; IX509NameValuePair *pPair = NULL; IX509NameValuePairs *pPairs = NULL; PCWSTR pwszName; PCWSTR pwszValue; PCWSTR pwszDnsName; PCWSTR pwszEKU; BSTR strCAConfig = NULL; BSTR strDnsName = NULL; BSTR strName = NULL; BSTR strValue = NULL; BSTR strEKU = NULL; BSTR strRequest = NULL; BSTR strCert = NULL; BSTR strDisposition = NULL; LONG pDisposition = 0; // Process command line arguments if (argc != 5) { Usage(); hr = E_INVALIDARG; _JumpError(hr, error, "invalid arg"); } else { pwszName = argv[1]; pwszValue = argv[2]; pwszDnsName = argv[3]; pwszEKU = argv[4]; } // CoInitializeEx hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); _JumpIfError(hr, error, "CoInitializeEx");

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      What are the setup instructions for the sample? Are the COM classes registered using regsvr32.exe?

      «_Superman_» I love work. It gives me something to do between weekends.
      Microsoft MVP (Visual C++)

      1 Reply Last reply
      0
      • B bahareh655

        Hi all I've built a sample code named "enrollCustomCMC" in Windows SDK at "Microsoft SDKs\Windows\v6.1\Samples\Security\X509 Certificate Enrollment\VC" directory, but when the ".exe" file is built and I use it with the "Command Prompt", I see error in first "CoCreateInstance" function as "REGDB_E_CLASSNOTREG" that means: "Class not registered"! I couldn't find the reason even with debugging! The code is written using COM interface, here's the code: #include #include #include #include #include #include "enrollCommon.h" void Usage() { wprintf(L"Usage:\n"); wprintf(L"enrollCustomCMC \n"); wprintf(L"Example: enrollCustomCMC Name Value "); wprintf(L"www.adatum.com 1.3.6.1.5.5.7.3.1\n"); } HRESULT __cdecl wmain(__in int argc, __in_ecount(argc) wchar_t *argv[]) { HRESULT hr = S_OK; bool fCoInit = false; ICertRequest2* pCertRequest2 = NULL; ICertConfig* pCertConfig = NULL; IX509Enrollment* pEnroll = NULL; IX509CertificateRequest* pRequest = NULL; IX509CertificateRequestPkcs10* pPkcs10 = NULL; IX509CertificateRequestCmc* pCmc = NULL; IX509Extensions* pExtensions = NULL; IX509Extension* pExtension1 = NULL; IX509Extension* pExtension2 = NULL; IX509ExtensionEnhancedKeyUsage* pExtensionEKU = NULL; IX509ExtensionAlternativeNames* pExtensionSAN = NULL; IObjectId *pEKUObjectId = NULL; IObjectId *pSANObjectId = NULL; IObjectIds *pEKUObjectIds = NULL; IObjectIds *pSANObjectIds = NULL; IAlternativeName * anDnsName = NULL; IAlternativeNames * pAlternativeNames = NULL; IX509NameValuePair *pPair = NULL; IX509NameValuePairs *pPairs = NULL; PCWSTR pwszName; PCWSTR pwszValue; PCWSTR pwszDnsName; PCWSTR pwszEKU; BSTR strCAConfig = NULL; BSTR strDnsName = NULL; BSTR strName = NULL; BSTR strValue = NULL; BSTR strEKU = NULL; BSTR strRequest = NULL; BSTR strCert = NULL; BSTR strDisposition = NULL; LONG pDisposition = 0; // Process command line arguments if (argc != 5) { Usage(); hr = E_INVALIDARG; _JumpError(hr, error, "invalid arg"); } else { pwszName = argv[1]; pwszValue = argv[2]; pwszDnsName = argv[3]; pwszEKU = argv[4]; } // CoInitializeEx hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); _JumpIfError(hr, error, "CoInitializeEx");

        M Offline
        M Offline
        Michel Godfroid
        wrote on last edited by
        #3

        The documentation clearly states that these API's are available starting with Windows Vista. So no XP :-(

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups