wm通过注册表获得UA

WM:

1.通过注册表

CString CTyydApp::GetUserAgent() { HKEY hKey = NULL; DWORD dwValue; LONG rc = NULL; CString strUserAgent = _T(""); rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"//Security//Internet Explorer//User Agent", 0, 0, &hKey); if (rc == ERROR_SUCCESS) { RegQueryValueEx(hKey, L"CustomBase", NULL, NULL, NULL, &dwValue); BYTE* pBuf = new BYTE[dwValue]; RegQueryValueEx(hKey, L"CustomBase", NULL, NULL, pBuf, &dwValue); strUserAgent.Format(L"%s", pBuf); delete[] pBuf; RegCloseKey(hKey); } return strUserAgent; }

 

 

 

你可能感兴趣的:(null,byte,delete)