source: trunk/Utilities/Miscellaneous/CoCreateInstance02/CoCreateInstance02.cpp @ 805

Last change on this file since 805 was 805, checked in by roman, 5 years ago
  • Property svn:mime-type set to application/octet-stream
File size: 3.3 KB
Line 
1#include <winsdkver.h>
2#include <sdkddkver.h>
3#include <mfapi.h>
4#include <mftransform.h>
5#include <stdio.h>
6#include <tchar.h>
7#include <atlbase.h>
8#include <atlcom.h>
9
10#pragma comment(lib, "mfuuid.lib")
11#pragma comment(lib, "mfplat.lib")
12
13int main()
14{
15        ATLVERIFY(SUCCEEDED(CoInitialize(NULL)));
16        {
17                ATLVERIFY(SUCCEEDED(MFStartup(MF_VERSION)));
18                class __declspec(uuid("{60F44560-5A20-4857-BFEF-D29773CB8040}")) CFoo; // NVIDIA H.264 Encoder MFT
19                CComPtr<IMFTransform> pTransform;
20                const HRESULT nCoCreateInstanceResult = pTransform.CoCreateInstance(__uuidof(CFoo));
21                _tprintf(_T("nCoCreateInstanceResult 0x%08X\n"), nCoCreateInstanceResult);
22                if(FAILED(nCoCreateInstanceResult))
23                {
24                        const HMODULE hModule = LoadLibrary(_T("nvEncMFTH264.dll"));
25                        _tprintf(_T("hModule 0x%p\n"), hModule);
26                        typedef HRESULT (STDMETHODCALLTYPE *DLLGETCLASSOBJECT)(__in REFCLSID ClassIdentifier, __in REFIID InterfaceIdentifier, __out VOID** ppvObject);
27                        const DLLGETCLASSOBJECT pDllGetClassObject = (DLLGETCLASSOBJECT) GetProcAddress(hModule, "DllGetClassObject");
28                        CComPtr<IClassFactory> pClassFactory;
29                        const HRESULT nDllGetClassObjectResult = (pDllGetClassObject)(__uuidof(CFoo), __uuidof(IClassFactory), (VOID**) &pClassFactory);
30                        _tprintf(_T("nDllGetClassObjectResult 0x%08X\n"), nDllGetClassObjectResult);
31                        ATLASSERT(pClassFactory);
32                        const HRESULT nCreateInstanceResult = pClassFactory->CreateInstance(NULL, __uuidof(IMFTransform), (VOID**) &pTransform.p);
33                        _tprintf(_T("nCreateInstanceResult 0x%08X\n"), nCreateInstanceResult);
34                        pTransform.Release();
35                        FreeLibrary(hModule);
36                }
37        }
38        CoUninitialize();
39    return 0;
40}
41
Note: See TracBrowser for help on using the repository browser.