⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 comcorelib.c

📁 vxworks源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
                       hint,                       TRUE,                       1,                       mqi);    if (FAILED (hr))        return hr;    if (ppvClsObj)        *ppvClsObj = mqi[0].pItf;    else        hr = E_INVALIDARG;    return hr;    }/**************************************************************************** comRegistryAdd - add a registry instance to the COM core** This function adds a registry instance to the table of all known* registries in the COM core. If there are no more spaces in the* registry table, it returns an error, otherwise the registry is added* to the end of the table.** RETURNS: S_OK if the registry instance was added, or some other error* code if not.*/HRESULT comRegistryAdd    (    const char *        regName,        /* registry name */    DWORD               dwClsCtx,       /* class context */    IRegistry*          pReg            /* registry to add */    )    {    HRESULT hr = REGDB_E_CLASSNOTREG;    int i;        /* Make sure the library is initialized... */    COM_CORE_LIB_INIT ();        /* Work forwards through the table of known registries, ensuring     * we add this registry instance at the end of the table.     */        for (i = 0; i < COM_CORE_MAX_REGISTRIES; ++i)        {        if (comCoreRegistries[i].pRegistry == NULL)            {            size_t len;                        /* Add a reference-count, and store the info. */            IUnknown_AddRef (pReg);                        len = strlen (regName);            comCoreRegistries[i].regName = malloc (len + 1);            strcpy (comCoreRegistries[i].regName, regName);                        comCoreRegistries[i].dwClsCtx = dwClsCtx;            comCoreRegistries[i].pRegistry = pReg;            /* We can leave now... */            hr = S_OK;            break;            }        }            return hr;    }/**************************************************************************** comClassRegister - registers a 'get-class-object' function for a CLSID** This function stores an association between the class ID <clsid> and* the 'get class object' function pointer <pfnGCO> so that instances* of the coclass can be created. The entry is made in the first known* registry that can deal with the class context given in <dwClsCtx>.** RETURNS: S_OK if the requested CLSID is found, or REGDB_E_CLASSNOTREG* if it is not present.*/HRESULT comClassRegister    (    REFCLSID	        clsid,		/* class ID */    DWORD               dwClsCtx,       /* class context */    PFN_GETCLASSOBJECT  pfnGCO,         /* GetClassObject() func */    VXDCOMPRIORITYSCHEME priScheme,     /* priority scheme */    int                 priority	/* priority assoc. with scheme */    )    {    HRESULT hr = REGDB_E_CLASSNOTREG;    int i;    IRegistry * pReg;        /* Make sure the library is initialized... */    COM_CORE_LIB_INIT ();        /* Work forwards through the table of known registries, looking     * for the first registry that can deal with this class.     */        for (i = 0; i < COM_CORE_MAX_REGISTRIES; ++i)        {        if ((comCoreRegistries[i].dwClsCtx & dwClsCtx) != 0)            {            /* Add to this registry. */            pReg = comCoreRegistries[i].pRegistry;            hr = IRegistry_RegisterClass (pReg, clsid, pfnGCO);            break;            }        }        return hr;    }/**************************************************************************** comCoreGUID2String - convert GUID to a printable string** Converts a GUID to a printable string.** RETURNS: S_OK**/HRESULT comCoreGUID2String    (    const GUID *        pGuid,          /* GUID to print */    char *              buf             /* GUID_STRING_LEN */    )    {    sprintf (buf,             "{%8.8X-%4.4X-%4.4X-%2.2X%2.2X-%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X}",             (unsigned int) pGuid->Data1,             (unsigned short)pGuid->Data2,             (unsigned short)pGuid->Data3,             pGuid->Data4[0],             pGuid->Data4[1],              pGuid->Data4[2],             pGuid->Data4[3],              pGuid->Data4[4],             pGuid->Data4[5],              pGuid->Data4[6],             pGuid->Data4[7]);    return S_OK;    }/**************************************************************************** comCoreRegShow - Displays a human readable version of the registry.** RETURNS: OK* NOMANUAL*/STATUS comCoreRegShow (void)    {    int i;        /* Make sure the library is initialized... */    COM_CORE_LIB_INIT ();        /* Work forwards through the table of known registries, getting     * the CLSIDs out of each one and printing them.     */        for (i = 0; i < COM_CORE_MAX_REGISTRIES; ++i)        {        IRegistry * pReg = comCoreRegistries[i].pRegistry;        if (pReg != NULL)            {            DWORD       ix = 0;            HRESULT     hr = S_OK;            CLSID       clsid;                        /* Add a ref while we use it... */            IUnknown_AddRef (pReg);            /* Print the title... */            printf ("%s:\n", comCoreRegistries[i].regName);                        /* Iterate over the CLSIDs... */            while (hr == S_OK)                {                char buf [GUID_STRING_LEN];                                hr = IRegistry_GetClassID (pReg, ix++, &clsid);                if (SUCCEEDED (hr))                    {                    comCoreGUID2String (&clsid, buf);                    printf ("%s\n", buf);                    }                }            /* Done - release the registry interface... */            IUnknown_Release (pReg);            }        }    return OK;    }/**************************************************************************** comGuidCmp - compare two GUIDs** This function compares two GUIDs and returns a true/false result.** RETURNS: TRUE if the GUIDs are identical, FALSE otherwise.**/BOOL comGuidCmp    (    const GUID *	g1,		/* Source GUID */    const GUID *	g2		/* GUID to compare to */    )    {    return memcmp (g1, g2, sizeof (GUID)) == 0;    }/**************************************************************************** comSafeInc - increments a variable in a task-safe way** This function increments a variable, guaranteeing that no other task* can simultaneously be modifying its value.** RETURNS: incremented value*/long comSafeInc    (    long *      pVar    )    {    long n;        TASK_LOCK ();    n = ++(*pVar);    TASK_UNLOCK ();    return n;    }/**************************************************************************** comSafeDec - decrements a variable in a task-safe way** This function decrements a variable, guaranteeing that no other task* can simultaneously be modifying its value.** RETURNS: decremented value*/long comSafeDec    (    long *      pVar    )    {    long n;        TASK_LOCK ();    n = --(*pVar);    TASK_UNLOCK ();    return n;    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -