Click here to Skip to main content
15,914,350 members
Home / Discussions / COM
   

COM

 
QuestionLaunch as interactive user Pin
SteveTheHalfB8-Oct-08 4:44
SteveTheHalfB8-Oct-08 4:44 
AnswerRe: Launch as interactive user Pin
SteveTheHalfB12-Oct-08 23:53
SteveTheHalfB12-Oct-08 23:53 
QuestionAssertion failed: _pAtlModule == 0 Pin
Christian Bayer6-Oct-08 6:51
Christian Bayer6-Oct-08 6:51 
QuestionRuns on Server, not on Workstations Pin
rahvyn133-Oct-08 6:32
rahvyn133-Oct-08 6:32 
QuestionHeaders created by MIDL, position of DECLSPEC_UUID Pin
Andreas Tondorf1-Oct-08 22:13
Andreas Tondorf1-Oct-08 22:13 
QuestionHow do I pass MySQL connection ID to COM using VC++ 9.0? Pin
Ger Hayden30-Sep-08 7:22
Ger Hayden30-Sep-08 7:22 
QuestionCOM add in for MS Office Outlook? Pin
maui_mike29-Sep-08 20:19
maui_mike29-Sep-08 20:19 
QuestionMMDeviceEnumerator registration problem Pin
punitkumar2629-Sep-08 13:09
punitkumar2629-Sep-08 13:09 
Hi,

I am using CLSID_MMDeviceEnumerator for creating the instance of MMDeviceEnumerator.However,the call CoCreateInstance is failing saying the class is not registered.Upon checking the CLSIDs in the registry,i found that its not there in registry.
What to do?

The below code is taken from MSDN.

// soundcard.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include<atlbase.h>

//#include "Winerror.h"
#include "Mmdeviceapi.h"
#include "Functiondiscoverykeys_devpkey.h"
//-----------------------------------------------------------
// This function enumerates all active (plugged in) audio
// rendering endpoint devices. It prints the friendly name
// and endpoint ID string of each endpoint device.
//-----------------------------------------------------------
#define EXIT_ON_ERROR(hres) \
if (FAILED(hres)) { goto Exit; }
#define SAFE_RELEASE(punk) \
if ((punk) != NULL) \
{ (punk)->Release(); (punk) = NULL; }

const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator);
const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);

void PrintEndpointNames()
{

HRESULT hr = S_OK;
IMMDeviceEnumerator *pEnumerator = NULL;
IMMDeviceCollection *pCollection = NULL;
IMMDevice *pEndpoint = NULL;
IPropertyStore *pProps = NULL;
LPWSTR pwszID = NULL;

hr = CoCreateInstance(
CLSID_MMDeviceEnumerator, NULL,
CLSCTX_INPROC_SERVER, IID_IMMDeviceEnumerator,
(void**)&pEnumerator);
EXIT_ON_ERROR(hr)

hr = pEnumerator->EnumAudioEndpoints(
eRender, DEVICE_STATE_ACTIVE,
&pCollection);
EXIT_ON_ERROR(hr)

UINT count;
hr = pCollection->GetCount(&count);
EXIT_ON_ERROR(hr)

if (count == 0)
{
printf("No endpoints found.\n");
}

// Each loop prints the name of an endpoint device.
for (ULONG i = 0; i < count; i++)
{
// Get pointer to endpoint number i.
hr = pCollection->Item(i, &pEndpoint);
EXIT_ON_ERROR(hr)

// Get the endpoint ID string.
hr = pEndpoint->GetId(&pwszID);
EXIT_ON_ERROR(hr)

hr = pEndpoint->OpenPropertyStore(
STGM_READ, &pProps);
EXIT_ON_ERROR(hr)

PROPVARIANT varName;
// Initialize container for property value.
PropVariantInit(&varName);

// Get the endpoint's friendly-name property.
hr = pProps->GetValue(
PKEY_Device_FriendlyName, &varName);
EXIT_ON_ERROR(hr)

// Print endpoint friendly name and endpoint ID.
printf("Endpoint %d: \"%S\" (%S)\n",
i, varName.pwszVal, pwszID);

CoTaskMemFree(pwszID);
pwszID = NULL;
PropVariantClear(&varName);
SAFE_RELEASE(pProps)
SAFE_RELEASE(pEndpoint)
}
SAFE_RELEASE(pEnumerator)
SAFE_RELEASE(pCollection)
return;

Exit:
printf("Error!\n");
CoTaskMemFree(pwszID);
SAFE_RELEASE(pEnumerator)
SAFE_RELEASE(pCollection)
SAFE_RELEASE(pEndpoint)
SAFE_RELEASE(pProps)
}

int _tmain(int argc, _TCHAR* argv[])
{ HRESULT hr=CoInitialize(NULL);
PrintEndpointNames();
::CoUninitialize();
return 0;
}
QuestionUsing C# and COM to connect to a Server Pin
SRogers8829-Sep-08 7:44
SRogers8829-Sep-08 7:44 
AnswerRe: Using C# and COM to connect to a Server Pin
alchong8-Oct-08 14:19
alchong8-Oct-08 14:19 
QuestionGet COM pointer to running instance of Yahoo Messenger. Pin
u0m326-Sep-08 7:02
u0m326-Sep-08 7:02 
QuestionHow to Include MFC Datatypes in IDl ? Pin
narayanagvs25-Sep-08 23:20
narayanagvs25-Sep-08 23:20 
QuestionExtra Chart in OWC11 (ASP)! Pin
marlboroguy5824-Sep-08 1:35
marlboroguy5824-Sep-08 1:35 
QuestionWord Automation Pin
g_dev23-Sep-08 18:37
g_dev23-Sep-08 18:37 
AnswerRe: Word Automation Pin
kattah28-Jan-09 13:03
kattah28-Jan-09 13:03 
QuestionWord Automation Pin
g_dev23-Sep-08 18:36
g_dev23-Sep-08 18:36 
Questionvc++ and .net Runtime error Pin
balu1234522-Sep-08 9:15
balu1234522-Sep-08 9:15 
QuestionSynchronization concepts.. [modified] Pin
kDevloper21-Sep-08 21:13
kDevloper21-Sep-08 21:13 
AnswerRe: Synchronization concepts.. Pin
John_Adams3-Oct-08 12:47
John_Adams3-Oct-08 12:47 
GeneralRe: Synchronization concepts.. Pin
kDevloper3-Oct-08 18:25
kDevloper3-Oct-08 18:25 
QuestionHow to draw sth. on owner flash ole container Pin
61934514220-Sep-08 14:38
61934514220-Sep-08 14:38 
QuestionDynamic DLL creation Pin
Member 400849215-Sep-08 3:11
Member 400849215-Sep-08 3:11 
QuestionC++ and COM Pin
bhogavalli suresh14-Sep-08 19:19
bhogavalli suresh14-Sep-08 19:19 
AnswerRe: C++ and COM Pin
Lim Bio Liong14-Sep-08 21:44
Lim Bio Liong14-Sep-08 21:44 
GeneralRe: C++ and COM Pin
Ju@ncho19-Sep-08 9:57
Ju@ncho19-Sep-08 9:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.