Condividi tramite


Funzione D3DKMTGetSharedPrimaryHandle (d3dkmthk.h)

La funzione D3DKMTGetSharedPrimaryHandle recupera l'handle condiviso globale per la superficie primaria.

Sintassi

NTSTATUS D3DKMTGetSharedPrimaryHandle(
  D3DKMT_GETSHAREDPRIMARYHANDLE *unnamedParam1
);

Parametri

unnamedParam1

pData [in, out]

Puntatore a una struttura D3DKMT_GETSHAREDPRIMARYHANDLE che descrive i parametri necessari per recuperare l'handle condiviso.

Valore restituito

D3DKMTGetSharedPrimaryHandle restituisce uno dei valori seguenti:

Codice restituito Descrizione
STATUS_SUCCESS L'handle è stato recuperato correttamente.
STATUS_DEVICE_REMOVED La scheda grafica è stata arrestata o il dispositivo di visualizzazione è stato reimpostato.
STATUS_INVALID_PARAMETER I parametri sono stati convalidati e sono stati determinati come non corretti.

Questa funzione potrebbe anche restituire altri valori NTSTATUS.

Commenti

La superficie primaria viene in genere creata dal sottosistema kernel grafico Microsoft DirectX (Dxgkrnl.sys) ogni volta che la modalità di visualizzazione cambia (anche se, in alcune situazioni, il database primario condiviso potrebbe non esistere). Se un'applicazione OpenGL tenta di creare una superficie primaria, in genere deve aprire il database primario condiviso esistente. Per aprire il database primario condiviso, l'applicazione OpenGL deve usare D3DKMTGetSharedPrimaryHandle per recuperare l'handle condiviso globale per la superficie primaria.

Esempio

Nell'esempio di codice seguente viene illustrato come una progettazione immagine e configurazione OpenGL possa usare D3DKMTGetSharedPrimaryHandle per creare una superficie primaria aprendo l'handle condiviso.

HRESULT OpenSharedPrimarySurface(D3DKMT_HANDLE hAdapter,
                                 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId,
                                 D3DKMT_HANDLE hDevice, 
                                 VOID* pPrivateDriverData,
                                 UINT PrivateDriverDataSize,
                                 D3DKMT_HANDLE* phResource,
                                 D3DKMT_HANDLE* phAllocation)
{
    D3DKMT_CREATEALLOCATION CreateAllocation;
    D3DDDI_ALLOCATIONINFO AllocationInfo;
    D3DKMT_GETSHAREDPRIMARYHANDLE GetHandleData;

    *phResource = 0;
    *phAllocation = 0;

    // Get the shared handle.
    GetHandleData.hAdapter = hAdapter;
    GetHandleData.VidPnSourceId = VidPnSourceId;

    if (!NT_SUCCESS((*pfnKTGetSharedPrimaryHandle)(&GetHandleData))) {
        return E_FAIL;
    }

    // Was a shared primary created by the kernel?
    if (GetHandleData.hSharedPrimary == NULL) {
        return E_FAIL;
    }

    CreateAllocation.hDevice = hDevice;
    CreateAllocation.hResource = NULL;
    CreateAllocation.hGlobalShare = GetHandleData.hSharedPrimary;
    CreateAllocation.Flags.CreateResource = 
    CreateAllocation.Flags.CreateShared = TRUE;
    CreateAllocation.pPrivateRuntimeData = NULL;
    CreateAllocation.PrivateRuntimeDataSize = 0;
    CreateAllocation.pPrivateDriverData = NULL;
    CreateAllocation.PrivateDriverDataSize = 0;
    CreateAllocation.NumAllocations = 1;
    CreateAllocation.pAllocationInfo = &AllocationInfo;

    AllocationInfo.hAllocation = NULL;
    AllocationInfo.pSystemMem = NULL;
    AllocationInfo.pPrivateDriverData = pPrivateData;
    AllocationInfo.PrivateDriverDataSize = PrivateDataSize;

    if (NT_SUCCESS((*pfnKTCreateAllocation)(&CreateAllocation))) {
        *phResource = CreateAllocation.hResource;
        *phAllocation = AllocationInfo.hAllocation;
        return S_OK;
    }
    return E_FAIL;
}

Requisiti

Requisito Valore
Client minimo supportato Windows Vista
Piattaforma di destinazione Universale
Intestazione d3dkmthk.h (include D3dkmthk.h)
Libreria Gdi32.lib
DLL Gdi32.dll

Vedi anche

D3DKMT_GETSHAREDPRIMARYHANDLE