示例#1
0
  void waitAtEndOfFrame()
  {
    uint64_t local_fence_value = fence_value;

    WINCHECK( commandQueue->Signal( fence, local_fence_value ) );
    ++fence_value;

    if( fence->GetCompletedValue() < local_fence_value )
    {
      WINCHECK( fence->SetEventOnCompletion( local_fence_value, fence_event ) );
      WaitForSingleObject( fence_event, INFINITE );
    }
  }
示例#2
0
ITypeLib* tCOMUtil::LoadTypeLibFromCLSID(CLSID clsid,
                                         unsigned short major_version)
{
  wchar_t* wcClsid = NULL;

  HRESULT hr = StringFromCLSID(clsid, &wcClsid);

  if (FAILED(hr))
    return NULL;

  /* converte CLSID para string normal */
  char* pcClsid = (char*) malloc( (wcslen(wcClsid) + 1) * sizeof(char));
  wcstombs(pcClsid, wcClsid,wcslen(wcClsid)+1);

  CoTaskMemFree(wcClsid);

  DWORD size = 38*3; /*{F37C8063-4AD5-101B-B826-00DD01103DE1}*/
  BYTE *bLibID = (BYTE *) malloc(size);
  BYTE bVersion[100]; // This must hold something like "5.2"
  HKEY iid_key, obj_key, typelib_key, version_key;

  /* extrai do registry type library (GUID e versao) */
  LONG res = 0;
  bool version_info_found = true;

  try
  {
    res = RegOpenKeyEx(HKEY_CLASSES_ROOT,"CLSID", 0, KEY_READ, &iid_key);
    WINCHECK(res == ERROR_SUCCESS);

    res = RegOpenKeyEx(iid_key, pcClsid, 0, KEY_READ, &obj_key);
    RegCloseKey(iid_key);
    free(pcClsid);
    pcClsid = NULL;

    WINCHECK(res == ERROR_SUCCESS);

    res = RegOpenKeyEx(obj_key, "TypeLib",0, KEY_READ, &typelib_key);
    if(res != ERROR_SUCCESS)
    {
      RegCloseKey(obj_key);
      LUACOM_EXCEPTION(WINDOWS_ERROR);
    }

    res = RegOpenKeyEx(obj_key, "version",0, KEY_READ, &version_key);
    RegCloseKey(obj_key);
    if(res != ERROR_SUCCESS)
      version_info_found = false;

    RegQueryValueEx(typelib_key, NULL, NULL, NULL, bLibID, &size);
    RegCloseKey(typelib_key);
        
    RegQueryValueEx(version_key, NULL, NULL, NULL, bVersion, &size);
    RegCloseKey(version_key);
  }
  catch(class tLuaCOMException& e)
  {
    UNUSED(e);

    if(pcClsid)
      free(pcClsid);

    return NULL;
  }

  // converts libID to multibyte string
  wchar_t* wcTypelib= (wchar_t*) 
    malloc( (strlen((char *) bLibID) + 1) * sizeof(wchar_t));
  mbstowcs(wcTypelib, (char *) bLibID, strlen((char *) bLibID)+1);

  // extracts version information

  int version_major = 0, version_minor = 0;

  int found = 0;

  if(version_info_found)
  {
    found = sscanf(
      (const char *) bVersion,
      "%d.%d",
      &version_major, &version_minor);
  }

  if(major_version > 0 &&
      (
        (!version_info_found) ||
        (version_info_found && found == 0)
      )
    )
  {
    version_major = major_version;
    version_minor = 0;
  }
  else if(!version_info_found)
  {
    // tries to load the first type library found in
    // the registry
    bool result = tCOMUtil::GetDefaultTypeLibVersion(
      (const char*) bLibID,
      &version_major,
      &version_minor);

    if(!result)
      return NULL;
  }

  free(bLibID);

  GUID libid = IID_NULL;
  CLSIDFromString(wcTypelib, &libid);
  free(wcTypelib);

  ITypeLib* typelib = NULL;

  hr = LoadRegTypeLib(libid, version_major, version_minor, 0, &typelib);

  if(FAILED(hr))
    return NULL;

  return typelib;
}