• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Let's hope XP doesn't keep this "one-up" on OS X!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Let's hope XP doesn't keep this "one-up" on OS X!


  • Subject: Re: Let's hope XP doesn't keep this "one-up" on OS X!
  • From: "John C. Randolph" <email@hidden>
  • Date: Wed, 4 Jul 2001 14:07:49 -0700

BTW, did you notice the sample code on that page?

HRESULT CoCreateOnConsoleWithBindToObject(REFCLSID rclsid, REFIID riid, void** ppv)
{
*ppv = NULL;

IBindCtx* pbc;
HRESULT hr = CreateBindCtx(0, &pbc);
if (SUCCEEDED(hr))
{
WCHAR sz[128], szClsid[64];

StringFromGUID2(rclsid, szClsid, ARRAYSIZE(szClsid));
LPWSTR psz = szClsid + 1; // skip "{"
while (*psz != L'}')
psz++;
*psz = NULL;

lstrcpyW(sz, L"Session:Console!clsid:");
lstrcatW(sz, &szClsid[1]);

// Parse the name and get a moniker:
ULONG ulEaten;
IMoniker* pmk;
hr = MkParseDisplayName(pbc, sz, &ulEaten, &pmk);
if (SUCCEEDED(hr))
{
IClassFactory *pcf;
hr = pmk->BindToObject(pbc, NULL, IID_PPV_ARG(IClassFactory, &pcf));
if (SUCCEEDED(hr))
{
hr = pcf->CreateInstance(NULL, riid, ppv);
pcf->Release();
}
pmk->Release();
}
pbc->Release();
}
return hr;
}

Please keep in mind that this is sample code and will not compile if it is just copied and pasted.

Why does that not suprise me in the slightest?

Don't you just love those macros like IID_PPV_ARG()?

I know I complain about having to use Carbon for some things in Mac OS X development, and I sure don't like procedural API's, but the old Mac Toolbox is at least a semi-coherent procedural API. If I had to code for the win32 API, I'd forget about computers and pursue a career in carpentry.

-jcr


"This is not a book to be tossed aside lightly. Rather, it should be hurled with great force." -Dorothy Parker


  • Follow-Ups:
    • Re: Let's hope XP doesn't keep this "one-up" on OS X!
      • From: Fritz Anderson <email@hidden>
References: 
 >Let's hope XP doesn't keep this "one-up" on OS X! (From: Ryan Dary <email@hidden>)

  • Prev by Date: Re: Let's hope XP doesn't keep this "one-up" on OS X!
  • Next by Date: Re: Let's hope XP doesn't keep this "one-up" on OS X!
  • Previous by thread: Re: Let's hope XP doesn't keep this "one-up" on OS X!
  • Next by thread: Re: Let's hope XP doesn't keep this "one-up" on OS X!
  • Index(es):
    • Date
    • Thread