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 in modo che non siano corretti.

Questa funzione potrebbe restituire anche altri valori NTSTATUS.

Osservazioni

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

esempio di

L'esempio di codice seguente illustra come una progettazione immagine e configurazione openGL può 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;
}

Fabbisogno

Requisito Valore
client minimo supportato Windows Vista
piattaforma di destinazione Universale
intestazione d3dkmthk.h (include D3dkmthk.h)
libreria Gdi32.lib
dll Gdi32.dll

Vedere anche

D3DKMT_GETSHAREDPRIMARYHANDLE