Condividi tramite


Compilazione del controllo di esempio dell'unità di estensione

Importante

Il contenuto e il codice di esempio in questo argomento sono obsoleti e attualmente non supportati. Potrebbe non funzionare con la toolchain di sviluppo dei driver corrente.

È possibile compilare il codice in questa sezione per creare un controllo unità di esempio dell'estensione UVC. Quando si compila questo progetto, si crea un controllo Microsoft ActiveX che è possibile usare con un'applicazione corrispondente per ottenere e impostare le proprietà in un'unità di estensione.

Per usare il controllo, è necessario hardware che implementa la funzionalità specifica dell'unità di estensione. In alternativa, è possibile usare un emulatore USB.

Per compilare il controllo, seguire questa procedura:

  1. Installare i pacchetti seguenti:

    • Microsoft Windows Server 2003 con Service Pack 1 (SP1) Driver Development Kit (DDK)
    • Aggiornamento di Microsoft DirectX 9.0 SDK (febbraio 2005)
    • Microsoft DirectX 9.0 Febbraio 2005 SDK Extra
  2. Copiare il codice di esempio dagli argomenti seguenti in singoli file.

    Interfaccia di esempio per le unità di estensione UVC

    DLL del plug-in unità di estensione di esempio

    Voce del Registro di sistema di esempio per le unità di estensione UVC

    Applicazione di esempio per unità di estensione UVC

    Supporto degli eventi di aggiornamento automatico con unità di estensione

    Specifica di un file INF UVC

  3. Creare un file di origini come segue:

    TARGETNAME= uvcxuplgn
    TARGETTYPE= DYNLINK
    TARGETPATH= obj
    TARGETEXT=  ax
    
    DLLENTRY=_DllMainCRTStartup
    DLLBASE=0x10080000
    USE_MSVCRT=1
    
    USE_STATIC_ATL=1
    
    USER_INCLUDES= $(O)
    
    INCLUDES=
    
    SOURCES= interface.idl \
     uvcxuplgn.cpp \
             stdafx.cpp    \
             interface_i.c \
             vidcap_i.c    \
             xuproxy.cpp
    
    TARGETLIBS= \
            $(SDK_LIB_PATH)\kernel32.lib          \
            $(SDK_LIB_PATH)\user32.lib            \
            $(SDK_LIB_PATH)\gdi32.lib             \
            $(SDK_LIB_PATH)\advapi32.lib          \
            $(SDK_LIB_PATH)\comdlg32.lib          \
            $(SDK_LIB_PATH)\ole32.lib             \
            $(SDK_LIB_PATH)\oleaut32.lib          \
            $(SDK_LIB_PATH)\uuid.lib              \
            $(SDK_LIB_PATH)\comctl32.lib
    
  4. Creare un file makefile come segue:

    #############################################################################
    #
    #       Copyright (C) Microsoft Corporation 1995
    #       All Rights Reserved.
    #
    #       MAKEFILE for WDM device driver kit
    #
    #############################################################################
    
    #
    # DO NOT EDIT THIS FILE!!!  Edit .\sources. if you want to add a new source
    # file to this component.  This file merely indirects to the real make file
    # that is shared by all the driver components of the Windows NT DDK
    #
    
    !if "$(WIN2K_DDKBUILD)" == ""
    !INCLUDE $(NTMAKEENV)\makefile.def
    !endif
    
  5. Usare lo strumento Guidgen.exe (incluso nel Microsoft Windows SDK) per creare tre GUID:

    • Usare il primo GUID come ID set di proprietà per l'unità di estensione. Sostituire i segnaposto GUID basati su x con il nuovo GUID in Xuproxy.h, Xusample.rgs,Xuplgin.inf e nel descrittore di unità di estensione a livello di hardware.
    • Usare il secondo GUID come IID per l'unità di estensione. Sostituire i segnaposto GUID basati su y con il nuovo GUID in Interface.idl e Xuplgin.inf.
    • Usare il terzo GUID come GUID di classe (clsid) per l'unità di estensione. Sostituire il segnaposto GUID basato su z con il nuovo GUID in Xuplgin.inf, Xuproxy.h e Xusample.rgs.
  6. Creare Uvcxuplgn.def come indicato di seguito:

    LIBRARY uvcxuplgn
    
    EXPORTS
        DllGetClassObject   PRIVATE
        DllCanUnloadNow     PRIVATE
        DllRegisterServer   PRIVATE
        DllUnregisterServer PRIVATE
    
  7. Creare Uvcxuplgn.cpp come indicato di seguito:

    #include "stdafx.h"
    CComModule _Module;
    #include <initguid.h>
    #include "interface.h"
    #include "xuproxy.h"
    BEGIN_OBJECT_MAP(ObjectMap)
    OBJECT_ENTRY(CLSID_ExtensionUnit, CExtension)
    END_OBJECT_MAP()
    
    STDAPI DllRegisterServer(void)
    {
        return _Module.RegisterServer(FALSE, NULL);
    }
    
    STDAPI DllUnregisterServer(void)
    {
        return _Module.UnregisterServer();
    }
    
    EXTERN_C
    BOOL
    DllMain(
        HINSTANCE   hinst,
        DWORD       dwReason,
        LPVOID      lpReserved)
    {
        switch (dwReason) {
            case DLL_PROCESS_ATTACH:
    
                _Module.Init (ObjectMap, hinst);
                break;
    
            case DLL_PROCESS_DETACH:
                _Module.Term();
                break;
        }
        return TRUE;
    }
    
    extern "C" STDMETHODIMP DllCanUnloadNow(void)
    {
        return _Module.GetLockCount()==0 ? S_OK : S_FALSE;
    }
    
    extern "C" STDAPI DllGetClassObject(
        REFCLSID    rclsid,
        REFIID      riid,
        LPVOID      *ppv)
    {
        return _Module.GetClassObject(rclsid, riid, ppv);
    }
    
  8. Creare Stdafx.h come indicato di seguito:

    // stdafx.h : include file for standard system include files,
    //      or project specific include files that are used frequently,
    //      but are changed infrequently
    
    #if !defined(AFX_STDAFX_H__722DC775_FE6F_42FB_BED5_E1E299976D17__INCLUDED_)
    #define AFX_STDAFX_H__722DC775_FE6F_42FB_BED5_E1E299976D17__INCLUDED_
    
    #if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000
    
    #define STRICT
    #ifndef _WIN32_WINNT
    #define _WIN32_WINNT 0x0400
    #endif
    #define _ATL_APARTMENT_THREADED
    
    #include <atlbase.h>
    //You may derive a class from CComModule and use it if you want to override
    //something, but do not change the name of _Module
    extern CComModule _Module;
    #include <atlcom.h>
    #include <atlctl.h>
    
    //{{AFX_INSERT_LOCATION}}
    // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
    
    #endif // !defined(AFX_STDAFX_H__722DC775_FE6F_42FB_BED5_E1E299976D17__INCLUDED)
    
  9. Creare Stdafx.cpp come indicato di seguito:

    // stdafx.cpp : source file that includes just the standard includes
    //  stdafx.pch will be the pre-compiled header
    //  stdafx.obj will contain the pre-compiled type information
    
    #include "stdafx.h"
    
    #ifdef _ATL_STATIC_REGISTRY
    #include <statreg.h>
    #include <statreg.cpp>
    #endif
    
    #include <atlimpl.cpp>
    
  10. Compilare l'esempio richiamando Build -cZg nell'ambiente di compilazione WDK.

Vedi anche

Esempi di codice di unità di estensione UVC

Interfaccia di esempio per le unità di estensione UVC

DLL del plug-in unità di estensione di esempio

Voce del Registro di sistema di esempio per le unità di estensione UVC

Applicazione di esempio per unità di estensione UVC

Supporto degli eventi di aggiornamento automatico con unità di estensione

Specifica di un file INF UVC