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

📄 ddpdb.c

📁 linux下的一款播放器
💻 C
📖 第 1 页 / 共 4 页
字号:
            IDirectDraw4_GetDeviceIdentifier(lpDD4, &ddID, DDGDI_GETHOSTIDENTIFIER) == DD_OK) ||            /* try to gather Win9x device information manually: */            GetWin9xDeviceID (&ddID)) {            /* clear best match criteria: */            deviceBestMatch = driverBestMatch = bestMatchIdx = 0;            /* scan database: */            for (i = 0; i < DDPDB.dwNumProfiles; i++) {                /* check platform ID: */                if (DDPDB.ddProfiles[i].dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {                    /* clear match criteria: */                    deviceMatch = driverMatch = 0;                    /* check non-critical parameters: */                    if (!DDPDB.ddProfiles[i].ID.Win9x.szDescription[0] ||                        !strncmp (DDPDB.ddProfiles[i].ID.Win9x.szDescription, ddID.szDescription, MAXDESCRIPT-1))                        deviceMatch ++;                    if (!DDPDB.ddProfiles[i].ID.Win9x.szDriver[0] ||                        !strnicmp (DDPDB.ddProfiles[i].ID.Win9x.szDriver, ddID.szDriver, MAXDRIVER-1))                        driverMatch ++;                    /* check critical data: */                    if (!DDPDB.ddProfiles[i].ID.Win9x.dwDriverVersionHighPart)                        driverMatch ++;                    else if (DDPDB.ddProfiles[i].ID.Win9x.dwDriverVersionHighPart == (DWORD)ddID.liDriverVersion.HighPart)                        driverMatch += 2;                    else                        continue;                    if (!DDPDB.ddProfiles[i].ID.Win9x.dwDriverVersionLowPart)                        driverMatch ++;                    else if (DDPDB.ddProfiles[i].ID.Win9x.dwDriverVersionLowPart == (DWORD)ddID.liDriverVersion.LowPart)                        driverMatch += 2;                    else                        continue;                    if (!DDPDB.ddProfiles[i].ID.Win9x.dwVendorId)                        deviceMatch ++;                    else if (DDPDB.ddProfiles[i].ID.Win9x.dwVendorId == ddID.dwVendorId)                        deviceMatch += 2;                    else                        continue;                    if (!DDPDB.ddProfiles[i].ID.Win9x.dwDeviceId)                        deviceMatch ++;                    else if (DDPDB.ddProfiles[i].ID.Win9x.dwDeviceId == ddID.dwDeviceId)                        deviceMatch += 2;                    else                        continue;                    /* check the results: */                    if (deviceMatch + driverMatch > deviceBestMatch + driverBestMatch &&                        deviceMatch >= deviceBestMatch && driverMatch >= driverBestMatch) {                        /* update best match: */                        deviceBestMatch = deviceMatch;                        driverBestMatch = driverMatch;                        bestMatchIdx  = i;                    }                }            }            /* check overal search results: */            if (deviceBestMatch >= 3 && driverBestMatch >= 3)                return DDPDB.ddProfiles + bestMatchIdx;        }#endif //DIRECTDRAW_VERSION <= 0x0500        /* return default profile: */        return &ddWin9xDefaultProfile;    }}/* packs 2-character string into a normal, single-character one: */static void PackWideString (char *dest, char *src, int n){    register char *d = dest, *s = src;    while (n-- && *s) {        *d = *s;        s += 2;        d += 1;    }    *d = '\0';}static BOOL GetFileVersion(LPTSTR pPath, LPDDDEVICEIDENTIFIER lpddID){    DWORD   dwVerInfoSize;    DWORD   dwVerHnd;    BOOL    fSuccess = FALSE;    // load version.dll    HINSTANCE		    hLib = NULL;    VERQUERYVALUE	    _pVerQueryValue = NULL;    GETFILEVERSIONINFO	    _pGetFileVersionInfo = NULL;    GETFILEVERSIONINFOSIZE  _pGetFileVersionInfoSize = NULL;    hLib = LoadLibrary("version.dll");    if (hLib)    {	_pVerQueryValue = (VERQUERYVALUE)GetProcAddress(hLib, "VerQueryValueA");	_pGetFileVersionInfo = (GETFILEVERSIONINFO)GetProcAddress(hLib, "GetFileVersionInfoA");	_pGetFileVersionInfoSize = (GETFILEVERSIONINFOSIZE)GetProcAddress(hLib, "GetFileVersionInfoSizeA");    }    if (_pVerQueryValue		&&	_pGetFileVersionInfo	&&	_pGetFileVersionInfoSize)    {	/* set everything to 0: */	lpddID->liDriverVersion.HighPart = 0;	lpddID->liDriverVersion.LowPart = 0;	/* get size of version info: */	if ((dwVerInfoSize = _pGetFileVersionInfoSize(pPath, &dwVerHnd)) != 0) {	    HANDLE  hMem;                     /* handle to mem alloc'ed */	    LPSTR   lpstrVffInfo;             /* Pointer to block to hold info */	    /* Get a block big enough to hold version info */	    hMem          = GlobalAlloc(GMEM_MOVEABLE, dwVerInfoSize);	    lpstrVffInfo  = (char *)GlobalLock(hMem);	    /* get file version info: */	    if (_pGetFileVersionInfo(pPath, dwVerHnd, dwVerInfoSize, lpstrVffInfo)) {		UINT    VersionLen;		LPSTR   lpVersion;		/* query version info: */		if (_pVerQueryValue(lpstrVffInfo, "\\",		    (void FAR* FAR*)&lpVersion, &VersionLen)) {		    /* copy version info: */		    VS_FIXEDFILEINFO* pFileInfo = (VS_FIXEDFILEINFO*)lpVersion;		    lpddID->liDriverVersion.HighPart = pFileInfo->dwFileVersionMS;		    lpddID->liDriverVersion.LowPart = pFileInfo->dwFileVersionLS;		    /* indicate success: */		    fSuccess = TRUE;		}	    }	    /* Let go of the memory */	    GlobalUnlock(hMem);	    GlobalFree(hMem);	}    }    FreeLibrary(hLib);    return fSuccess;}#define MAX_BUF        512#ifdef TRACE#define Trace(pMsg)  printf("-->%s\n", pMsg)#else#define Trace(pMsg)  ((void)0)#endif/* * This whole thing is based on Jeff's CFullScreenInfo:: code: */BOOL GetWinNTDeviceID (LPDDDEVICEIDENTIFIER lpddID, char *pszChipType){    HKEY        hKey;    char        szBuffer[MAX_BUF];    DWORD       bufSize  = sizeof(szBuffer) - 1;
    char        pDLLPath[_MAX_PATH];    const char* pszStrip = "\\registry\\machine\\";    LONG        res = ERROR_SUCCESS;    BOOL        retVal = FALSE;        /* open Hardware\\DEVICEMAP\\VIDEO key: */    res = RegOpenKeyEx( HKEY_LOCAL_MACHINE,                        "Hardware\\DEVICEMAP\\VIDEO",                        0,                        KEY_READ,                        &hKey                        );        if( ERROR_SUCCESS == res )    {        /* query a Video0 entry: */        memset(szBuffer, 0, sizeof(szBuffer) );        res = RegQueryValueEx(hKey,                              "\\Device\\Video0",                              NULL,                              NULL,                              (LPBYTE) szBuffer,                              (LPDWORD)&bufSize);        //Done with first key.        RegCloseKey(hKey);                if( ERROR_SUCCESS == res )        {            //Find \Registry\Machine in the key's values and strip it            //off. Some machines write the key in different cases.            //If we can't find it, something is wrong. It also must            //be at the start of the string.            _strlwr( szBuffer );            if( strstr(szBuffer, pszStrip) == szBuffer )            {                res = RegOpenKeyEx(HKEY_LOCAL_MACHINE,                                   szBuffer + strlen(pszStrip), //Skip pre-log.                                   0,                                   KEY_READ,                                   &hKey);                if( res == ERROR_SUCCESS )                {                    /* get Device Description: */                    memset( szBuffer, 0, sizeof(szBuffer) );                    bufSize = sizeof( szBuffer)-1;                    res = RegQueryValueEx( hKey,                                           "HardwareInformation.AdapterString",                                           NULL,                                           NULL,                                           (LPBYTE) szBuffer,                                           (LPDWORD)&bufSize);                                if( ERROR_SUCCESS == res )                    {                        /* move it to dddid: */                        PackWideString(lpddID->szDescription, szBuffer, MAXDESCRIPT-1);                        /* get ChipType information: */                        memset( szBuffer, 0, sizeof(szBuffer) );                        bufSize = sizeof( szBuffer)-1;                        res = RegQueryValueEx( hKey,                                               "HardwareInformation.ChipType",                                               NULL,                                               NULL,                                               (LPBYTE) szBuffer,                                               (LPDWORD)&bufSize);                                    if( ERROR_SUCCESS == res )                        {                            /* copy it: */                            PackWideString (pszChipType, szBuffer, MAXCHIPTYPE-1);                            /* get driver name: */                            memset( szBuffer, 0, sizeof(szBuffer) );                            bufSize = sizeof( szBuffer)-1;                            res = RegQueryValueEx( hKey,                                                   "InstalledDisplayDrivers",                                                   NULL,                                                   NULL,                                                   (LPBYTE) szBuffer,                                                   (LPDWORD)&bufSize);                            if( ERROR_SUCCESS == res && bufSize )                            {                                //copy driver name                                strcat(szBuffer, ".dll");                                strncpy(lpddID->szDriver, szBuffer, MAXDRIVER-1);                                // get full path to the driver:                                if(GetSystemDirectory(pDLLPath, _MAX_PATH) != 0)                                {                                    strcat(pDLLPath, "\\");                                    strcat(pDLLPath, szBuffer);                                    // query file version:                                    if( GetFileVersion(pDLLPath, lpddID) )                                    {                                        retVal = TRUE;                                    }                                                                    }                            }                        }                    }                    RegCloseKey(hKey);                }            }        }    }        return retVal;}static BOOL DevNodeIsActive(char *szDeviceID){    HINSTANCE hDevNodeInst;    DWORD dwStatus;    DWORD dwProblemNumber;    DWORD cr;    DWORD (WINAPI *pGetDevNodeStatus32Call) (const char *, LPDWORD, LPDWORD);    /*     * 10 is a magic number for the configuration manager api     * that eventually gets called in the 16 bit dll.     */    dwStatus = dwProblemNumber = cr = 10;    pGetDevNodeStatus32Call = 0;    if ((hDevNodeInst = LoadLibrary(_32BIT_DLLNAME)) != 0)    {        if (((FARPROC)pGetDevNodeStatus32Call = GetProcAddress(hDevNodeInst, "GetDevNodeStatus32Call")) != NULL)        {            cr = (* pGetDevNodeStatus32Call) (szDeviceID, &dwStatus, &dwProblemNumber);        }        FreeLibrary(hDevNodeInst);    }    return cr == 0 && dwProblemNumber == 0;}static unsigned int hex2uint (char *p, int n){    register unsigned int i = 0;    while (n--)    {        register unsigned int j = *p;        i <<= 4;        if (j <= '9')   j -= '0';        else            j -= 'A' - 10;        p ++;        i |= j;    }    return i;}/* * Extract Win9x DirectDraw device information: */BOOL GetWin9xDeviceID (LPDDDEVICEIDENTIFIER lpddID){    static char *szEnum_Name [ENUM_MAX] = {        REGSTR_KEY_ROOTENUM, REGSTR_KEY_BIOSENUM,        REGSTR_KEY_PCIENUM,  REGSTR_KEY_ISAENUM,        REGSTR_KEY_EISAENUM, REGSTR_KEY_PCMCIAENUM    };    /* moved out of stack for safety reasons... */    static char szCurrentKey [MAX_BUF];    static char szCurrentDeviceNode[MAX_BUF];    static char szCurrentDevice [MAX_BUF];    static char szClass [64];    static char szDeviceID [MAX_BUF];    static char szSoftwareKey [MAX_BUF];    static char pDLLPath [_MAX_PATH];    ULONG ulType;    ULONG32 cbData;    HKEY hSoftwareKey;

⌨️ 快捷键说明

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