本文整理匯總了C++中CoCreateInstance函數的典型用法代碼示例。如果您正苦於以下問題:C++ CoCreateInstance函數的具體用法?C++ CoCreateInstance怎麽用?C++ CoCreateInstance使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CoCreateInstance函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: AMovieDllRegisterServer2
STDAPI
AMovieDllRegisterServer2( BOOL bRegister )
{
HRESULT hr = NOERROR;
DbgLog((LOG_TRACE, 2, TEXT("AMovieDllRegisterServer2()")));
// get file name (where g_hInst is the
// instance handle of the filter dll)
//
WCHAR achFileName[MAX_PATH];
// WIN95 doesn't support GetModuleFileNameW
//
{
char achTemp[MAX_PATH];
DbgLog((LOG_TRACE, 2, TEXT("- get module file name")));
// g_hInst handle is set in our dll entry point. Make sure
// DllEntryPoint in dllentry.cpp is called
ASSERT(g_hInst != 0);
if( 0 == GetModuleFileNameA( g_hInst
, achTemp
, sizeof(achTemp) ) )
{
// we've failed!
DWORD dwerr = GetLastError();
return AmHresultFromWin32(dwerr);
}
MultiByteToWideChar( CP_ACP
, 0L
, achTemp
, lstrlenA(achTemp) + 1
, achFileName
, NUMELMS(achFileName) );
}
//
// first registering, register all OLE servers
//
if( bRegister )
{
DbgLog((LOG_TRACE, 2, TEXT("- register OLE Servers")));
hr = RegisterAllServers( achFileName, TRUE );
}
//
// next, register/unregister all filters
//
if( SUCCEEDED(hr) )
{
// init is ref counted so call just in case
// we're being called cold.
//
DbgLog((LOG_TRACE, 2, TEXT("- CoInitialize")));
hr = CoInitialize( (LPVOID)NULL );
ASSERT( SUCCEEDED(hr) );
// get hold of IFilterMapper2
//
DbgLog((LOG_TRACE, 2, TEXT("- obtain IFilterMapper2")));
IFilterMapper2 *pIFM2 = 0;
IFilterMapper *pIFM = 0;
hr = CoCreateInstance( CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC_SERVER
, IID_IFilterMapper2
, (void **)&pIFM2 );
if(FAILED(hr))
{
DbgLog((LOG_TRACE, 2, TEXT("- trying IFilterMapper instead")));
hr = CoCreateInstance(
CLSID_FilterMapper,
NULL,
CLSCTX_INPROC_SERVER,
IID_IFilterMapper,
(void **)&pIFM);
}
if( SUCCEEDED(hr) )
{
// scan through array of CFactoryTemplates
// registering servers and filters.
//
DbgLog((LOG_TRACE, 2, TEXT("- register Filters")));
for( int i = 0; i < g_cTemplates; i++ )
{
// get i'th template
//
const CFactoryTemplate *pT = &g_Templates[i];
if( NULL != pT->m_pAMovieSetup_Filter )
{
DbgLog((LOG_TRACE, 2, TEXT("- - register %ls"), (LPCWSTR)pT->m_Name ));
if(pIFM2)
//.........這裏部分代碼省略.........
示例2: WASAPI_Thread
static int WASAPI_Thread(void *arg)
{
soundcardinfo_t *sc = arg;
qboolean inited = false;
// REFERENCE_TIME hnsRequestedDuration = REFTIMES_PER_SEC;
IMMDeviceEnumerator *pEnumerator = NULL;
IMMDevice *pDevice = NULL;
IAudioClient *pAudioClient = NULL;
IAudioRenderClient *pRenderClient = NULL;
UINT32 bufferFrameCount;
HANDLE hEvent = NULL;
WAVEFORMATEX *pwfx;
qboolean exclusive = Cvar_Get("wasapi_exclusive", "1", 0, "WASAPI audio output")->ival;
void *cond = sc->handle;
//main thread will wait for us to finish initing, so lets do that...
CoInitialize(NULL);
if (SUCCEEDED(CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &IID_IMMDeviceEnumerator, (void**)&pEnumerator)))
if (SUCCEEDED(pEnumerator->lpVtbl->GetDefaultAudioEndpoint(pEnumerator, eRender, eConsole, &pDevice)))
if (SUCCEEDED(pDevice->lpVtbl->Activate(pDevice, &IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&pAudioClient)))
{
if (!WASAPI_DetermineFormat(sc, pAudioClient, exclusive, &pwfx))
{
Con_Printf("WASAPI: unable to determine mutually supported audio format\n");
}
else
{
if (sc->sn.samplebits && (!snd_speed || sc->sn.speed == snd_speed))
{
HRESULT hr;
REFERENCE_TIME buffersize = REFTIMES_PER_SEC * Cvar_Get("wasapi_buffersize", "0.01", 0, "WASAPI audio output")->ival;
if (exclusive)
pAudioClient->lpVtbl->GetDevicePeriod(pAudioClient, NULL, &buffersize);
hr = pAudioClient->lpVtbl->Initialize(pAudioClient, exclusive?AUDCLNT_SHAREMODE_EXCLUSIVE:AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_EVENTCALLBACK, buffersize, (exclusive?buffersize:0), pwfx, NULL);
if (hr == AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED)
{ //this is stupid, but does what the documentation says should be done.
if (SUCCEEDED(pAudioClient->lpVtbl->GetBufferSize(pAudioClient, &bufferFrameCount)))
{
if (pAudioClient)
pAudioClient->lpVtbl->Release(pAudioClient);
pAudioClient = NULL;
if (SUCCEEDED(pDevice->lpVtbl->Activate(pDevice, &IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&pAudioClient)))
{
buffersize = (REFERENCE_TIME)((10000.0 * 1000 / pwfx->nSamplesPerSec * bufferFrameCount) + 0.5);
hr = pAudioClient->lpVtbl->Initialize(pAudioClient, exclusive?AUDCLNT_SHAREMODE_EXCLUSIVE:AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_EVENTCALLBACK, buffersize, (exclusive?buffersize:0), pwfx, NULL);
}
}
}
if (SUCCEEDED(hr))
{
hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if (hEvent)
{
pAudioClient->lpVtbl->SetEventHandle(pAudioClient, hEvent);
if (SUCCEEDED(pAudioClient->lpVtbl->GetBufferSize(pAudioClient, &bufferFrameCount)))
if (SUCCEEDED(pAudioClient->lpVtbl->GetService(pAudioClient, &IID_IAudioRenderClient, (void**)&pRenderClient)))
inited = true;
}
}
else
{
switch(hr)
{
case AUDCLNT_E_UNSUPPORTED_FORMAT:
Con_Printf("WASAPI Initialize: AUDCLNT_E_UNSUPPORTED_FORMAT\n");
break;
case AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED:
Con_Printf("WASAPI Initialize: AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED\n");
break;
case AUDCLNT_E_EXCLUSIVE_MODE_ONLY:
Con_Printf("WASAPI Initialize: AUDCLNT_E_EXCLUSIVE_MODE_ONLY\n");
break;
case AUDCLNT_E_DEVICE_IN_USE:
Con_Printf("WASAPI Initialize: AUDCLNT_E_DEVICE_IN_USE\n");
break;
case AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED:
Con_Printf("WASAPI Initialize: AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED\n");
break;
case E_INVALIDARG:
Con_Printf("WASAPI Initialize: E_INVALIDARG\n");
break;
default:
Con_Printf("pAudioClient->lpVtbl->Initialize failed (%x)\n", (unsigned int)hr);
}
}
}
CoTaskMemFree(pwfx);
}
}
if (inited)
//.........這裏部分代碼省略.........
示例3: CoInitialize
BOOL LLDXHardware::getInfo(BOOL vram_only)
{
LLTimer hw_timer;
BOOL ok = FALSE;
HRESULT hr;
CoInitialize(NULL);
IDxDiagProvider *dx_diag_providerp = NULL;
IDxDiagContainer *dx_diag_rootp = NULL;
IDxDiagContainer *devices_containerp = NULL;
// IDxDiagContainer *system_device_containerp= NULL;
IDxDiagContainer *device_containerp = NULL;
IDxDiagContainer *file_containerp = NULL;
IDxDiagContainer *driver_containerp = NULL;
// CoCreate a IDxDiagProvider*
LL_DEBUGS("AppInit") << "CoCreateInstance IID_IDxDiagProvider" << LL_ENDL;
hr = CoCreateInstance(CLSID_DxDiagProvider,
NULL,
CLSCTX_INPROC_SERVER,
IID_IDxDiagProvider,
(LPVOID*) &dx_diag_providerp);
if (FAILED(hr))
{
LL_WARNS("AppInit") << "No DXDiag provider found! DirectX 9 not installed!" << LL_ENDL;
gWriteDebug("No DXDiag provider found! DirectX 9 not installed!\n");
goto LCleanup;
}
if (SUCCEEDED(hr)) // if FAILED(hr) then dx9 is not installed
{
// Fill out a DXDIAG_INIT_PARAMS struct and pass it to IDxDiagContainer::Initialize
// Passing in TRUE for bAllowWHQLChecks, allows dxdiag to check if drivers are
// digital signed as logo'd by WHQL which may connect via internet to update
// WHQL certificates.
DXDIAG_INIT_PARAMS dx_diag_init_params;
ZeroMemory(&dx_diag_init_params, sizeof(DXDIAG_INIT_PARAMS));
dx_diag_init_params.dwSize = sizeof(DXDIAG_INIT_PARAMS);
dx_diag_init_params.dwDxDiagHeaderVersion = DXDIAG_DX9_SDK_VERSION;
dx_diag_init_params.bAllowWHQLChecks = TRUE;
dx_diag_init_params.pReserved = NULL;
LL_DEBUGS("AppInit") << "dx_diag_providerp->Initialize" << LL_ENDL;
hr = dx_diag_providerp->Initialize(&dx_diag_init_params);
if(FAILED(hr))
{
goto LCleanup;
}
LL_DEBUGS("AppInit") << "dx_diag_providerp->GetRootContainer" << LL_ENDL;
hr = dx_diag_providerp->GetRootContainer( &dx_diag_rootp );
if(FAILED(hr) || !dx_diag_rootp)
{
goto LCleanup;
}
HRESULT hr;
// Get display driver information
LL_DEBUGS("AppInit") << "dx_diag_rootp->GetChildContainer" << LL_ENDL;
hr = dx_diag_rootp->GetChildContainer(L"DxDiag_DisplayDevices", &devices_containerp);
if(FAILED(hr) || !devices_containerp)
{
goto LCleanup;
}
// Get device 0
LL_DEBUGS("AppInit") << "devices_containerp->GetChildContainer" << LL_ENDL;
hr = devices_containerp->GetChildContainer(L"0", &device_containerp);
if(FAILED(hr) || !device_containerp)
{
goto LCleanup;
}
// Get the English VRAM string
{
std::string ram_str = get_string(device_containerp, L"szDisplayMemoryEnglish");
// We don't need the device any more
SAFE_RELEASE(device_containerp);
// Dump the string as an int into the structure
char *stopstring;
mVRAM = strtol(ram_str.c_str(), &stopstring, 10);
LL_INFOS("AppInit") << "VRAM Detected: " << mVRAM << " DX9 string: " << ram_str << LL_ENDL;
}
if (vram_only)
{
ok = TRUE;
goto LCleanup;
}
/* for now, we ONLY do vram_only the rest of this
is commented out, to ensure no-one is tempted
to use it
//.........這裏部分代碼省略.........
示例4: pix_movieDS
pix_movieDS :: pix_movieDS(t_symbol *filename) :
m_haveMovie(FALSE),
m_frame(NULL),
m_csize(0),
m_xsize(0),
m_ysize(0),
FilterGraph(NULL),
VideoFilter(NULL),
SampleFilter(NULL),
NullFilter(NULL),
SampleGrabber(NULL),
MediaControl(NULL),
MediaSeeking(NULL),
MediaPosition(NULL)
{
HRESULT RetVal;
m_dataSize[0] = m_csize;
m_dataSize[1] = m_xsize;
m_dataSize[2] = m_ysize;
// Initialize COM
CoInitialize(NULL);
// Create the base object of a filter graph
RetVal = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)&FilterGraph);
if (RetVal != S_OK || NULL == FilterGraph)
{
error("Unable to create FilterGraph interface %d", RetVal);
return;
}
// Get the IMediaControl interface for Run, Stop, Pause and keeps control states
RetVal = FilterGraph->QueryInterface(IID_IMediaControl, (void **)&MediaControl);
if (RetVal != S_OK || NULL == MediaControl)
{
error("Unable to create MediaControl interface %d", RetVal);
return;
}
// Get the IMediaSeeking interface for rewinding video at loop point
// and set time format to frames
RetVal = FilterGraph->QueryInterface(IID_IMediaSeeking, (void **)&MediaSeeking);
if (RetVal != S_OK || NULL == MediaSeeking)
{
error("Unable to create MediaSeeking interface %d", RetVal);
return;
}
// Get the IMediaPosition interface for getting the current position of the clip
RetVal = FilterGraph->QueryInterface(IID_IMediaPosition, (void **)&MediaPosition);
if (RetVal != S_OK || NULL == MediaPosition)
{
error("Unable to create MediaPosition interface %d", RetVal);
return;
}
if (strlen(filename->s_name) > 0)
{
openMess(filename, GL_RGBA);
}
}
示例5: gst_dshow_find_filter
gboolean
gst_dshow_find_filter (CLSID input_majortype, CLSID input_subtype,
CLSID output_majortype, CLSID output_subtype,
gchar * prefered_filter_name, IBaseFilter ** filter)
{
gboolean ret = FALSE;
HRESULT hres;
GUID arrayInTypes[2];
GUID arrayOutTypes[2];
IFilterMapper2 *mapper = NULL;
IEnumMoniker *enum_moniker = NULL;
IMoniker *moniker = NULL;
ULONG fetched;
gchar *prefered_filter_upper = NULL;
gboolean exit = FALSE;
/* initialize output parameter */
if (filter)
*filter = NULL;
/* create a private copy of prefered filter substring in upper case */
if (prefered_filter_name) {
prefered_filter_upper = g_strdup (prefered_filter_name);
_strupr (prefered_filter_upper);
}
hres = CoCreateInstance (CLSID_FilterMapper2, NULL, CLSCTX_INPROC,
IID_IFilterMapper2, (void **) &mapper);
if (FAILED (hres))
goto clean;
memcpy (&arrayInTypes[0], &input_majortype, sizeof (CLSID));
memcpy (&arrayInTypes[1], &input_subtype, sizeof (CLSID));
memcpy (&arrayOutTypes[0], &output_majortype, sizeof (CLSID));
memcpy (&arrayOutTypes[1], &output_subtype, sizeof (CLSID));
hres =
mapper->EnumMatchingFilters (&enum_moniker, 0, FALSE,
MERIT_DO_NOT_USE + 1, TRUE, 1, arrayInTypes, NULL, NULL, FALSE, TRUE, 1,
arrayOutTypes, NULL, NULL);
if (FAILED (hres))
goto clean;
enum_moniker->Reset ();
while (hres = enum_moniker->Next (1, &moniker, &fetched), hres == S_OK
&& !exit) {
IBaseFilter *filter_temp = NULL;
IPropertyBag *property_bag = NULL;
gchar *friendly_name = NULL;
hres =
moniker->BindToStorage (NULL, NULL, IID_IPropertyBag,
(void **) &property_bag);
if (SUCCEEDED (hres) && property_bag) {
VARIANT varFriendlyName;
VariantInit (&varFriendlyName);
hres = property_bag->Read (L"FriendlyName", &varFriendlyName, NULL);
if (hres == S_OK && varFriendlyName.bstrVal) {
friendly_name =
g_utf16_to_utf8 ((const gunichar2 *) varFriendlyName.bstrVal,
wcslen (varFriendlyName.bstrVal), NULL, NULL, NULL);
if (friendly_name)
_strupr (friendly_name);
SysFreeString (varFriendlyName.bstrVal);
}
property_bag->Release ();
}
hres =
moniker->BindToObject (NULL, NULL, IID_IBaseFilter,
(void **) &filter_temp);
if (SUCCEEDED (hres) && filter_temp) {
ret = TRUE;
if (filter) {
if (*filter)
(*filter)->Release ();
*filter = filter_temp;
(*filter)->AddRef ();
if (prefered_filter_upper && friendly_name &&
strstr (friendly_name, prefered_filter_upper))
exit = TRUE;
}
/* if we just want to know if the formats are supported OR
if we don't care about what will be the filter used
=> we can stop enumeration */
if (!filter || !prefered_filter_upper)
exit = TRUE;
filter_temp->Release ();
}
if (friendly_name)
g_free (friendly_name);
moniker->Release ();
}
//.........這裏部分代碼省略.........
示例6: WndProc
// Handles all the windows messages we might receive
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static bool gDragging = false;
static uint8_t mouse_down = 0;
// Messages we registered for manually (no const value)
if (message == s_WmTaskbarList)
{
// Grab the Windows 7 taskbar list stuff
if (gTaskbarList)
gTaskbarList->Release();
HRESULT result = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_ALL, IID_ITaskbarList3, (void**)&gTaskbarList);
if (FAILED(result))
gTaskbarList = nil;
return 0;
}
// Handle messages
switch (message) {
case WM_TIMECHANGE:
// To prevent cheating and keep things better synchronized,
// we will completely re-eval the offsets on the next NetMsg we
// get from the server
if (plNetClientMgr* nc = plNetClientMgr::GetInstance())
nc->ResetServerTimeOffset(true);
break;
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_LBUTTONDBLCLK:
case WM_MBUTTONDBLCLK:
case WM_MBUTTONDOWN:
case WM_RBUTTONDBLCLK:
// Ensure we don't leave the client area during clicks
if (!(mouse_down++))
SetCapture(hWnd);
// fall through to old case
case WM_KEYDOWN:
case WM_CHAR:
// If they did anything but move the mouse, quit any intro movie playing.
if (gClient)
{
gClient->SetQuitIntro(true);
// normal input processing
if (gClient->WindowActive() && gClient->GetInputManager())
gClient->GetInputManager()->HandleWin32ControlEvent(message, wParam, lParam, hWnd);
}
break;
case WM_LBUTTONUP:
case WM_RBUTTONUP:
case WM_MBUTTONUP:
// Stop hogging the cursor
if (!(--mouse_down))
ReleaseCapture();
// fall through to input processing
case WM_MOUSEWHEEL:
case WM_KEYUP:
if (gClient && gClient->WindowActive() && gClient->GetInputManager())
gClient->GetInputManager()->HandleWin32ControlEvent(message, wParam, lParam, hWnd);
break;
case WM_MOUSEMOVE:
{
if (gClient && gClient->GetInputManager())
gClient->GetInputManager()->HandleWin32ControlEvent(message, wParam, lParam, hWnd);
}
break;
case WM_SYSKEYUP:
case WM_SYSKEYDOWN:
{
if (gClient && gClient->WindowActive() && gClient->GetInputManager())
{
gClient->GetInputManager()->HandleWin32ControlEvent(message, wParam, lParam, hWnd);
}
//DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_SYSCOMMAND:
switch (wParam) {
// Trap ALT so it doesn't pause the app
case SC_KEYMENU :
//// disable screensavers and monitor power downs too.
case SC_SCREENSAVE:
case SC_MONITORPOWER:
return 0;
case SC_CLOSE :
// kill game if window is closed
gClient->SetDone(TRUE);
if (plNetClientMgr * mgr = plNetClientMgr::GetInstance())
mgr->QueueDisableNet(false, nil);
DestroyWindow(gClient->GetWindowHandle());
break;
}
break;
case WM_SETCURSOR:
//.........這裏部分代碼省略.........
示例7: GetSystemDirectory
bool SPXAudio::Load()
{
TCHAR Buffer[MAX_PATH];
GetSystemDirectory(Buffer, MAX_PATH);
SPString path = SPString(Buffer) + L"\\XAudio2_7.dll";
if(PathFileExists( path.c_str()) == FALSE)
{
// Register xaudio
SPLogHelper::WriteLog(L"[XAudio] Copying XAudio " + path );
CopyFile(L"XAudio2_7.dll", path.c_str(), TRUE);
SPLogHelper::WriteLog("[XAudio] Registering XAudio ..." );
UINT result = WinExec("regsvr32.exe XAudio2_7.dll ", SW_HIDE);
}
//void* fnc = GetProcAddress(module, "XAudio2Create");
SPLogHelper::WriteLog("[XAudio] Initializing XAudio ...");
HRESULT hr = S_OK;//CoInitializeEx(NULL, COINIT_MULTITHREADED);
if (FAILED(hr) && hr != -2147417850)
{
SPLogHelper::WriteLog("[XAudio] ERROR: Failed to initialize XAudio2!");
SPMessageHelper::Msg("Failed to initialize XAudio2!");
return false;
}
IXAudio2* pXAudio2;
hr = CoCreateInstance((0 & XAUDIO2_DEBUG_ENGINE) ? __uuidof(XAudio2_Debug) : __uuidof(XAudio2),
NULL, CLSCTX_INPROC_SERVER, __uuidof(IXAudio2), (void**)&pXAudio2);
if (SUCCEEDED(hr))
{
hr = pXAudio2->Initialize(0, XAUDIO2_DEFAULT_PROCESSOR);
if (SUCCEEDED(hr))
{
xAudio = pXAudio2;
}
else
{
pXAudio2->Release();
}
}
else
{
SPLogHelper::WriteLog("[XAudio] ERROR: Failed to create XAudio2! %d %d", __uuidof(IXAudio2), __uuidof(XAudio2_Debug));
}
//hr = XAudio2Create( &xAudio, 0, XAUDIO2_DEFAULT_PROCESSOR );
if (FAILED(hr))
{
SPLogHelper::WriteLog("[XAudio] ERROR: Failed to create XAudio2! %d %d", hr, GetLastError());
SPMessageHelper::Msg("Failed to create XAudio2!");
return false;
}
// Enumerate and select devices
UINT32 deviceCount;
xAudio->GetDeviceCount(&deviceCount);
XAUDIO2_DEVICE_DETAILS deviceDetails;
int preferredDevice = 0;
for (unsigned int i = 0; i < deviceCount; i++)
{
xAudio->GetDeviceDetails(i,&deviceDetails);
if (deviceDetails.OutputFormat.Format.nChannels > 2)
{
preferredDevice = i;
break;
}
}
// Create mastering voice device
if ( FAILED(xAudio->CreateMasteringVoice( &masterVoice, XAUDIO2_DEFAULT_CHANNELS,
XAUDIO2_DEFAULT_SAMPLERATE, 0, preferredDevice, NULL ) ) )
{
SPLogHelper::WriteLog("[XAudio] WARNING: Failed to create Mastering Voice!");
//MessageBoxA(NULL, "Failed to create mastering voice!", NULL, NULL);
Unload();
return false;
}
return true;
}
示例8: _tmain
int _tmain(int argc, _TCHAR* argv[]) {
IMMDeviceEnumerator *enumerator = 0;
IMMDevice *device = 0;
FILE *f;
f=fopen("c:/1.wav","w");
CoInitialize(0);
CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator),
(void**) &enumerator);
enumerator->GetDefaultAudioEndpoint(eRender, eConsole, &device);
HANDLE processOutWrite, processOutRead, processInWrite, processInRead;
/*wchar_t processCommand[2000];
{
FILE* commandFile;
fopen_s(&commandFile, "command.txt", "r");
char cmd[2000];
fread(cmd, sizeof(char), 2000, commandFile);
fclose(commandFile);
size_t count;
mbstowcs_s(&count, processCommand, cmd, 2000);
}*/
/*{
//create pipes for plink process
SECURITY_ATTRIBUTES pipeAttributes = {0};
pipeAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
pipeAttributes.bInheritHandle = TRUE;
pipeAttributes.lpSecurityDescriptor= NULL;
CreatePipe(&processOutRead, &processOutWrite, &pipeAttributes, 0);
CreatePipe(&processInRead, &processInWrite, &pipeAttributes, 0);
STARTUPINFO startupInfo;
ZeroMemory(&startupInfo, sizeof(STARTUPINFO));
startupInfo.cb = sizeof(STARTUPINFO);
startupInfo.hStdError = processOutWrite;
startupInfo.hStdOutput = processOutWrite;
startupInfo.hStdInput = processInRead;
startupInfo.dwFlags |= STARTF_USESTDHANDLES;
PROCESS_INFORMATION processInfo = {0};
//launch process
CreateProcess(NULL, processCommand, NULL, NULL, TRUE, 0, NULL, NULL, &startupInfo, &processInfo);
//wait for plink to connect to minimze sound delay (magic number)
Sleep(2500);
}*/
HRESULT hr;
// activate an IAudioClient
IAudioClient *audioClient;
hr = device->Activate(__uuidof(IAudioClient), CLSCTX_ALL, NULL, (void**) &audioClient);
if (FAILED(hr)) {
printf("IMMDevice::Activate(IAudioClient) failed: hr = 0x%08x", hr);
return hr;
}
// get the default device format
WAVEFORMATEX *waveFormat;
hr = audioClient->GetMixFormat(&waveFormat);
if (FAILED(hr)) {
printf("IAudioClient::GetMixFormat failed: hr = 0x%08x\n", hr);
CoTaskMemFree(waveFormat);
audioClient->Release();
return hr;
}
// coerce int-16 wave format
// can do this in-place since we're not changing the size of the format
// also, the engine will auto-convert from float to int for us
switch (waveFormat->wFormatTag) {
case WAVE_FORMAT_IEEE_FLOAT:
waveFormat->wFormatTag = WAVE_FORMAT_PCM;
waveFormat->wBitsPerSample = 16;
waveFormat->nBlockAlign = waveFormat->nChannels * waveFormat->wBitsPerSample / 8;
waveFormat->nAvgBytesPerSec = waveFormat->nBlockAlign * waveFormat->nSamplesPerSec;
break;
case WAVE_FORMAT_EXTENSIBLE:
{
// naked scope for case-local variable
PWAVEFORMATEXTENSIBLE waveFormatEx = reinterpret_cast<PWAVEFORMATEXTENSIBLE>(waveFormat);
if (IsEqualGUID(KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, waveFormatEx->SubFormat)) {
waveFormatEx->SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
waveFormatEx->Samples.wValidBitsPerSample = 16;
waveFormat->wBitsPerSample = 16;
waveFormat->nBlockAlign = waveFormat->nChannels * waveFormat->wBitsPerSample / 8;
waveFormat->nAvgBytesPerSec = waveFormat->nBlockAlign * waveFormat->nSamplesPerSec;
} else {
printf("Don't know how to coerce mix format to int-16\n");
CoTaskMemFree(waveFormat);
audioClient->Release();
return E_UNEXPECTED;
}
}
break;
default:
printf("Don't know how to coerce WAVEFORMATEX with wFormatTag = 0x%08x to int-16\n", waveFormat->wFormatTag);
CoTaskMemFree(waveFormat);
audioClient->Release();
//.........這裏部分代碼省略.........
示例9: CoCreateInstance
HRESULT CDevice::GetSupportedContentTypes(
IPortableDevicePropVariantCollection** ppContentTypes)
{
HRESULT hr = S_OK;
if(ppContentTypes)
{
CComPtr<IPortableDeviceValues> pParams;
CComPtr<IPortableDeviceValues> pResults;
// Prepare to make a call to query for the content types
hr = CoCreateInstance(CLSID_PortableDeviceValues,
NULL,
CLSCTX_INPROC_SERVER,
IID_IPortableDeviceValues,
(VOID**)&pParams);
CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceValues");
if (hr == S_OK)
{
hr = CoCreateInstance(CLSID_PortableDeviceValues,
NULL,
CLSCTX_INPROC_SERVER,
IID_IPortableDeviceValues,
(VOID**)&pResults);
CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceValues for results");
}
// Set the params
if (hr == S_OK)
{
hr = pParams->SetGuidValue(WPD_PROPERTY_COMMON_COMMAND_CATEGORY, WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_CONTENT_TYPES.fmtid);
CHECK_HR(hr, ("Failed to set WPD_PROPERTY_COMMON_COMMAND_CATEGORY"));
}
if (hr == S_OK)
{
hr = pParams->SetUnsignedIntegerValue(WPD_PROPERTY_COMMON_COMMAND_ID, WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_CONTENT_TYPES.pid);
CHECK_HR(hr, ("Failed to set WPD_PROPERTY_COMMON_COMMAND_ID"));
}
if (hr == S_OK)
{
hr = pParams->SetGuidValue(WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_CATEGORY, WPD_FUNCTIONAL_CATEGORY_ALL);
CHECK_HR(hr, ("Failed to set WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_CATEGORY"));
}
// Make the call
if (hr == S_OK)
{
hr = m_pWpdBaseDriver->DispatchWpdMessage(pParams, pResults);
CHECK_HR(hr, ("Failed to dispatch message to get supported content types"));
}
if (hr == S_OK)
{
hr = pResults->GetIPortableDevicePropVariantCollectionValue(WPD_PROPERTY_CAPABILITIES_CONTENT_TYPES, ppContentTypes);
CHECK_HR(hr, ("Failed to get WPD_PROPERTY_CAPABILITIES_CONTENT_TYPES"));
}
}
return hr;
}
示例10: fz_load_jxr_or_info
static fz_pixmap *
fz_load_jxr_or_info(fz_context *ctx, unsigned char *data, int size, int *wp, int *hp, int *xresp, int *yresp, fz_colorspace **cspacep)
{
#ifdef _WIN32
int info_only = wp && hp && xresp && yresp && cspacep;
fz_pixmap *pix = NULL;
IStream *stream = NULL;
IWICImagingFactory *factory = NULL;
IWICBitmapDecoder *decoder = NULL;
IWICFormatConverter *converter = NULL;
IWICBitmapFrameDecode *src_frame = NULL;
IWICBitmapSource *src_bitmap = NULL;
int codec_available = 0;
LARGE_INTEGER zero = { 0 };
UINT width, height;
double xres, yres;
ULONG written;
HRESULT hr;
hr = CoInitialize(NULL);
if (FAILED(hr))
fz_throw(ctx, "JPEG-XR codec is not available");
#define Check(hr) if (FAILED(hr)) goto CleanUp
Check(CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_ALL, &IID_IWICImagingFactory, (void **)&factory));
Check(CreateStreamOnHGlobal(NULL, TRUE, &stream));
Check(IStream_Write(stream, data, (ULONG)size, &written));
Check(IStream_Seek(stream, zero, STREAM_SEEK_SET, NULL));
Check(IWICImagingFactory_CreateDecoderFromStream(factory, stream, NULL, WICDecodeMetadataCacheOnDemand, &decoder));
Check(IWICImagingFactory_CreateFormatConverter(factory, &converter));
Check(IWICBitmapDecoder_GetFrame(decoder, 0, &src_frame));
Check(IUnknown_QueryInterface(src_frame, &IID_IWICBitmapSource, &src_bitmap));
Check(IWICFormatConverter_Initialize(converter, src_bitmap, &GUID_WICPixelFormat32bppBGRA, WICBitmapDitherTypeNone, NULL, 0.f, WICBitmapPaletteTypeCustom));
Check(IWICFormatConverter_GetSize(converter, &width, &height));
Check(IWICFormatConverter_GetResolution(converter, &xres, &yres));
#undef Check
codec_available = 1;
if (info_only)
{
*cspacep = fz_device_bgr;
*wp = width;
*hp = height;
*xresp = (int)(xres + 0.5);
*yresp = (int)(yres + 0.5);
}
else
{
fz_try(ctx)
{
pix = fz_new_pixmap(ctx, fz_device_bgr, width, height);
}
fz_catch(ctx)
{
pix = NULL;
goto CleanUp;
}
hr = IWICFormatConverter_CopyPixels(converter, NULL, pix->w * pix->n, pix->w * pix->h * pix->n, pix->samples);
if (FAILED(hr))
{
fz_drop_pixmap(ctx, pix);
pix = NULL;
goto CleanUp;
}
pix->xres = (int)(xres + 0.5);
pix->yres = (int)(yres + 0.5);
}
CleanUp:
#define Release(unk) if (unk) IUnknown_Release(unk)
Release(src_bitmap);
Release(converter);
Release(src_frame);
Release(decoder);
Release(factory);
Release(stream);
#undef Release
CoUninitialize();
if (codec_available)
{
if (!pix && !info_only)
fz_throw(ctx, "JPEG-XR codec failed to decode the image");
return pix;
}
#endif
fz_throw(ctx, "JPEG-XR codec is not available");
return NULL;
}
示例11: create_system_ports_list
static void create_system_ports_list(IDirectMusic8Impl* object)
{
port_info * port;
const WCHAR emulated[] = {' ','[','E','m','u','l','a','t','e','d',']',0};
ULONG nb_ports;
ULONG nb_midi_out;
ULONG nb_midi_in;
MIDIOUTCAPSW caps_out;
MIDIINCAPSW caps_in;
IDirectMusicSynth8* synth;
HRESULT hr;
ULONG i;
TRACE("(%p)\n", object);
/* NOTE:
- it seems some native versions get the rest of devices through dmusic32.EnumLegacyDevices...*sigh*...which is undocumented
- should we enum wave devices ? Native does not seem to
*/
nb_midi_out = midiOutGetNumDevs();
nb_midi_in = midiInGetNumDevs();
nb_ports = 1 /* midi mapper */ + nb_midi_out + nb_midi_in + 1 /* synth port */;
port = object->system_ports = HeapAlloc(GetProcessHeap(), 0, nb_ports * sizeof(port_info));
if (!object->system_ports)
return;
/* Fill common port caps for all winmm ports */
for (i = 0; i < (nb_ports - 1 /* synth port*/); i++)
{
object->system_ports[i].caps.dwSize = sizeof(DMUS_PORTCAPS);
object->system_ports[i].caps.dwType = DMUS_PORT_WINMM_DRIVER;
object->system_ports[i].caps.dwMemorySize = 0;
object->system_ports[i].caps.dwMaxChannelGroups = 1;
object->system_ports[i].caps.dwMaxVoices = 0;
object->system_ports[i].caps.dwMaxAudioChannels = 0;
object->system_ports[i].caps.dwEffectFlags = DMUS_EFFECT_NONE;
/* Fake port GUID */
object->system_ports[i].caps.guidPort = IID_IUnknown;
object->system_ports[i].caps.guidPort.Data1 = i + 1;
}
/* Fill midi mapper port info */
port->device = MIDI_MAPPER;
port->create = DMUSIC_CreateMidiOutPortImpl;
midiOutGetDevCapsW(MIDI_MAPPER, &caps_out, sizeof(caps_out));
strcpyW(port->caps.wszDescription, caps_out.szPname);
strcatW(port->caps.wszDescription, emulated);
port->caps.dwFlags = DMUS_PC_SHAREABLE;
port->caps.dwClass = DMUS_PC_OUTPUTCLASS;
port++;
/* Fill midi out port info */
for (i = 0; i < nb_midi_out; i++)
{
port->device = i;
port->create = DMUSIC_CreateMidiOutPortImpl;
midiOutGetDevCapsW(i, &caps_out, sizeof(caps_out));
strcpyW(port->caps.wszDescription, caps_out.szPname);
strcatW(port->caps.wszDescription, emulated);
port->caps.dwFlags = DMUS_PC_SHAREABLE | DMUS_PC_EXTERNAL;
port->caps.dwClass = DMUS_PC_OUTPUTCLASS;
port++;
}
/* Fill midi in port info */
for (i = 0; i < nb_midi_in; i++)
{
port->device = i;
port->create = DMUSIC_CreateMidiInPortImpl;
midiInGetDevCapsW(i, &caps_in, sizeof(caps_in));
strcpyW(port->caps.wszDescription, caps_in.szPname);
strcatW(port->caps.wszDescription, emulated);
port->caps.dwFlags = DMUS_PC_EXTERNAL;
port->caps.dwClass = DMUS_PC_INPUTCLASS;
port++;
}
/* Fill synth port info */
port->create = DMUSIC_CreateSynthPortImpl;
hr = CoCreateInstance(&CLSID_DirectMusicSynth, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynth8, (void**)&synth);
if (SUCCEEDED(hr))
{
port->caps.dwSize = sizeof(port->caps);
hr = IDirectMusicSynth8_GetPortCaps(synth, &port->caps);
IDirectMusicSynth8_Release(synth);
}
if (FAILED(hr))
nb_ports--;
object->nb_system_ports = nb_ports;
}
示例12: MCA_do_file_dialog
//.........這裏部分代碼省略.........
MCRemoteFileDialog(ep, p_title, p_prompt, t_filters, t_filter_count, t_initial_folder, t_initial_file, (p_options & MCA_OPTION_SAVE_DIALOG) != 0, (p_options & MCA_OPTION_PLURAL) != 0);
free(t_filters);
return 0;
}
Window t_window;
t_window = MCModeGetParentWindow();
bool t_succeeded;
int t_filter_index;
if (MCmajorosversion >= 0x0600)
{
static SHCreateItemFromParsingNamePtr s_shcreateitemfromparsingname = NULL;
if (s_shcreateitemfromparsingname == NULL)
{
static HMODULE s_shell32_module = NULL;
s_shell32_module = LoadLibraryA("shell32.dll");
s_shcreateitemfromparsingname = (SHCreateItemFromParsingNamePtr)GetProcAddress(s_shell32_module, "SHCreateItemFromParsingName");
}
IFileSaveDialog *t_file_save_dialog;
IFileOpenDialog *t_file_open_dialog;
IFileDialog *t_file_dialog;
t_file_dialog = NULL;
HRESULT t_hresult;
if ((p_options & MCA_OPTION_SAVE_DIALOG) == 0)
{
t_hresult = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, __uuidof(IFileOpenDialog), (LPVOID *)&t_file_open_dialog);
t_succeeded = SUCCEEDED(t_hresult);
t_file_dialog = t_file_open_dialog;
}
else
{
t_hresult = CoCreateInstance(CLSID_FileSaveDialog, NULL, CLSCTX_INPROC_SERVER, __uuidof(IFileSaveDialog), (LPVOID *)&t_file_save_dialog);
t_succeeded = SUCCEEDED(t_hresult);
t_file_dialog = t_file_save_dialog;
}
if (t_succeeded)
{
DWORD t_options;
t_options = FOS_FORCEFILESYSTEM | FOS_NOCHANGEDIR | FOS_PATHMUSTEXIST;
if (p_options & MCA_OPTION_PLURAL)
t_options |= FOS_ALLOWMULTISELECT;
if (p_options & MCA_OPTION_SAVE_DIALOG)
t_options |= FOS_OVERWRITEPROMPT;
if (p_options & MCA_OPTION_FOLDER_DIALOG)
t_options |= FOS_PICKFOLDERS;
else
t_options |= FOS_FILEMUSTEXIST;
t_hresult = t_file_dialog -> SetOptions(t_options);
t_succeeded = SUCCEEDED(t_hresult);
}
if (t_succeeded && t_initial_folder != NULL)
{
示例13: AMovieDllRegisterServer
STDAPI
AMovieDllRegisterServer( void )
{
HRESULT hr = NOERROR;
// get file name (where g_hInst is the
// instance handle of the filter dll)
//
WCHAR achFileName[MAX_PATH];
{
// WIN95 doesn't support GetModuleFileNameW
//
char achTemp[MAX_PATH];
if( 0 == GetModuleFileNameA( g_hInst
, achTemp
, sizeof(achTemp) ) )
{
// we've failed!
DWORD dwerr = GetLastError();
return AmHresultFromWin32(dwerr);
}
MultiByteToWideChar( CP_ACP
, 0L
, achTemp
, lstrlenA(achTemp) + 1
, achFileName
, NUMELMS(achFileName) );
}
// scan through array of CFactoryTemplates
// registering servers and filters.
//
for( int i = 0; i < g_cTemplates; i++ )
{
// get i'th template
//
const CFactoryTemplate *pT = &g_Templates[i];
// register CLSID and InprocServer32
//
hr = AMovieSetupRegisterServer( *(pT->m_ClsID)
, (LPCWSTR)pT->m_Name
, achFileName );
// instantiate all servers and get hold of
// IAMovieSetup, if implemented, and call
// IAMovieSetup.Register() method
//
if( SUCCEEDED(hr) && (NULL != pT->m_lpfnNew) )
{
// instantiate object
//
PAMOVIESETUP psetup;
hr = CoCreateInstance( *(pT->m_ClsID)
, 0
, CLSCTX_INPROC_SERVER
, IID_IAMovieSetup
, reinterpret_cast<void**>(&psetup) );
if( SUCCEEDED(hr) )
{
hr = psetup->Unregister();
if( SUCCEEDED(hr) )
hr = psetup->Register();
psetup->Release();
}
else
{
if( (E_NOINTERFACE == hr )
|| (VFW_E_NEED_OWNER == hr ) )
hr = NOERROR;
}
}
// check final error for this pass
// and break loop if we failed
//
if( FAILED(hr) )
break;
} // end-for
return hr;
}
示例14: MkProtocol_StartEx
static HRESULT WINAPI MkProtocol_StartEx(IInternetProtocolEx *iface, IUri *pUri,
IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
DWORD grfPI, HANDLE *dwReserved)
{
MkProtocol *This = impl_from_IInternetProtocolEx(iface);
LPWSTR mime, progid, display_name, colon_ptr;
DWORD bindf=0, eaten=0, scheme=0, len;
BSTR url, path = NULL;
IParseDisplayName *pdn;
BINDINFO bindinfo;
STATSTG statstg;
IMoniker *mon;
HRESULT hres;
CLSID clsid;
TRACE("(%p)->(%p %p %p %08x %p)\n", This, pUri, pOIProtSink,
pOIBindInfo, grfPI, dwReserved);
hres = IUri_GetScheme(pUri, &scheme);
if(FAILED(hres))
return hres;
if(scheme != URL_SCHEME_MK)
return INET_E_INVALID_URL;
memset(&bindinfo, 0, sizeof(bindinfo));
bindinfo.cbSize = sizeof(BINDINFO);
hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
if(FAILED(hres)) {
WARN("GetBindInfo failed: %08x\n", hres);
return hres;
}
ReleaseBindInfo(&bindinfo);
IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_SENDINGREQUEST, NULL);
hres = IUri_GetDisplayUri(pUri, &url);
if(FAILED(hres))
return hres;
hres = FindMimeFromData(NULL, url, NULL, 0, NULL, 0, &mime, 0);
SysFreeString(url);
if(SUCCEEDED(hres)) {
IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_MIMETYPEAVAILABLE, mime);
CoTaskMemFree(mime);
}
hres = IUri_GetPath(pUri, &path);
if(FAILED(hres))
return hres;
len = SysStringLen(path)+1;
hres = UrlUnescapeW(path, NULL, &len, URL_UNESCAPE_INPLACE);
if (FAILED(hres)) {
SysFreeString(path);
return report_result(pOIProtSink, INET_E_RESOURCE_NOT_FOUND, ERROR_INVALID_PARAMETER);
}
progid = path+1; /* skip '@' symbol */
colon_ptr = strchrW(path, ':');
if(!colon_ptr) {
SysFreeString(path);
return report_result(pOIProtSink, INET_E_RESOURCE_NOT_FOUND, ERROR_INVALID_PARAMETER);
}
len = strlenW(path);
display_name = heap_alloc((len+1)*sizeof(WCHAR));
memcpy(display_name, path, (len+1)*sizeof(WCHAR));
progid[colon_ptr-progid] = 0; /* overwrite ':' with NULL terminator */
hres = CLSIDFromProgID(progid, &clsid);
SysFreeString(path);
if(FAILED(hres))
{
heap_free(display_name);
return report_result(pOIProtSink, INET_E_RESOURCE_NOT_FOUND, ERROR_INVALID_PARAMETER);
}
hres = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
&IID_IParseDisplayName, (void**)&pdn);
if(FAILED(hres)) {
WARN("Could not create object %s\n", debugstr_guid(&clsid));
heap_free(display_name);
return report_result(pOIProtSink, hres, ERROR_INVALID_PARAMETER);
}
hres = IParseDisplayName_ParseDisplayName(pdn, NULL /* FIXME */, display_name, &eaten, &mon);
heap_free(display_name);
IParseDisplayName_Release(pdn);
if(FAILED(hres)) {
WARN("ParseDisplayName failed: %08x\n", hres);
return report_result(pOIProtSink, hres, ERROR_INVALID_PARAMETER);
}
if(This->stream) {
IStream_Release(This->stream);
This->stream = NULL;
}
hres = IMoniker_BindToStorage(mon, NULL /* FIXME */, NULL, &IID_IStream, (void**)&This->stream);
IMoniker_Release(mon);
if(FAILED(hres)) {
//.........這裏部分代碼省略.........
示例15: CHECK_HR
HRESULT CDevice::GetDeviceFriendlyName(
__deref_out_opt LPWSTR* pwszDeviceFriendlyName)
{
HRESULT hr = S_OK;
CComPtr<IPortableDeviceValues> pParams;
CComPtr<IPortableDeviceValues> pResults;
CComPtr<IPortableDeviceKeyCollection> pKeys;
CComPtr<IPortableDeviceValues> pValues;
if (pwszDeviceFriendlyName == NULL)
{
hr = E_POINTER;
CHECK_HR(hr, "Cannot have NULL parameter");
return hr;
}
*pwszDeviceFriendlyName = NULL;
// Prepare to make a call to query for the device friendly name
if (hr == S_OK)
{
hr = CoCreateInstance(CLSID_PortableDeviceValues, NULL, CLSCTX_INPROC_SERVER, IID_IPortableDeviceValues, (VOID**)&pParams);
CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceValues");
}
if (hr == S_OK)
{
hr = CoCreateInstance(CLSID_PortableDeviceValues, NULL, CLSCTX_INPROC_SERVER, IID_IPortableDeviceValues, (VOID**)&pResults);
CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceValues");
}
if (hr == S_OK)
{
hr = CoCreateInstance(CLSID_PortableDeviceKeyCollection, NULL, CLSCTX_INPROC_SERVER, IID_IPortableDeviceKeyCollection, (VOID**)&pKeys);
CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceKeyCollection for results");
}
// Set the params
if (hr == S_OK)
{
hr = pParams->SetGuidValue(WPD_PROPERTY_COMMON_COMMAND_CATEGORY, WPD_COMMAND_OBJECT_PROPERTIES_GET.fmtid);
CHECK_HR(hr, ("Failed to set WPD_PROPERTY_COMMON_COMMAND_CATEGORY"));
}
if (hr == S_OK)
{
hr = pParams->SetUnsignedIntegerValue(WPD_PROPERTY_COMMON_COMMAND_ID, WPD_COMMAND_OBJECT_PROPERTIES_GET.pid);
CHECK_HR(hr, ("Failed to set WPD_PROPERTY_COMMON_COMMAND_ID"));
}
if (hr == S_OK)
{
hr = pParams->SetStringValue(WPD_PROPERTY_OBJECT_PROPERTIES_OBJECT_ID, WPD_DEVICE_OBJECT_ID);
CHECK_HR(hr, ("Failed to set WPD_PROPERTY_OBJECT_PROPERTIES_OBJECT_ID"));
}
if (hr == S_OK)
{
hr = pKeys->Add(WPD_DEVICE_FRIENDLY_NAME);
CHECK_HR(hr, ("Failed to add WPD_DEVICE_FRIENDLY_NAME to key collection"));
}
if (hr == S_OK)
{
hr = pParams->SetIPortableDeviceKeyCollectionValue(WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_KEYS, pKeys);
CHECK_HR(hr, ("Failed to set WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_KEYS"));
}
// Make the call
if (hr == S_OK)
{
hr = m_pWpdBaseDriver->DispatchWpdMessage(pParams, pResults);
CHECK_HR(hr, ("Failed to dispatch message to get supported content types"));
}
if (hr == S_OK)
{
hr = pResults->GetIPortableDeviceValuesValue(WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_VALUES, &pValues);
CHECK_HR(hr, ("Failed to get WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_VALUES"));
}
if (hr == S_OK)
{
hr = pValues->GetStringValue(WPD_DEVICE_FRIENDLY_NAME, pwszDeviceFriendlyName);
CHECK_HR(hr, ("Failed to get WPD_DEVICE_FRIENDLY_NAME"));
}
return hr;
}