⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setupapi.pas

📁 human interface devices.zip 一套组件
💻 PAS
📖 第 1 页 / 共 5 页
字号:
{******************************************************************}
{                                                                  }
{       Borland Delphi Runtime Library                             }
{       Setup and Device Installer API interface unit              }
{                                                                  }
{ Portions created by Microsoft are                                }
{ Copyright (C) 1995-1999 Microsoft Corporation.                   }
{ All Rights Reserved.                                             }
{                                                                  }
{ The original file is: setupapi.h, released March 1999.           }
{ The original Pascal code is: SetupApi.pas, released 29 Jan 2000. }
{ The initial developer of the Pascal code is Robert Marquardt     }
{ (robert_marquardt att gmx dott de)                               }
{                                                                  }
{ Portions created by Robert Marquardt are                         }
{ Copyright (C) 1999 Robert Marquardt.                             }
{                                                                  }
{ Contributor(s): Marcel van Brakel (brakelm att bart dott nl)     }
{                                                                  }
{ Obtained through:                                                }
{ Joint Endeavour of Delphi Innovators (Project JEDI)              }
{                                                                  }
{ You may retrieve the latest version of this file at the Project  }
{ JEDI home page, located at http://delphi-jedi.org                }
{                                                                  }
{ The contents of this file are used with permission, subject to   }
{ the Mozilla Public License Version 1.1 (the "License"); you may  }
{ not use this file except in compliance with the License. You may }
{ obtain a copy of the License at                                  }
{ http://www.mozilla.org/MPL/MPL-1.1.html                          }
{                                                                  }
{ Software distributed under the License is distributed on an      }
{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or   }
{ implied. See the License for the specific language governing     }
{ rights and limitations under the License.                        }
{                                                                  }
{******************************************************************}

unit SetupApi;

{$I windowsversion.inc}

interface

{$WEAKPACKAGEUNIT ON}

// (rom) this is the switch to change between static and dynamic linking.
// (rom) it is enabled by default here.
// (rom) To disable simply change the '$' to a '.'.
{$DEFINE SETUPAPI_LINKONREQUEST}

(*$HPPEMIT '#include "setupapi.h"'*)

uses
  Windows, CommCtrl,
  {$IFDEF SETUPAPI_LINKONREQUEST}
  ModuleLoader,
  {$ENDIF SETUPAPI_LINKONREQUEST}
  WinConvTypes;

const
  ANYSIZE_ARRAY = 1;
  {$EXTERNALSYM ANYSIZE_ARRAY}

//
// Define maximum string length constants as specified by
// Windows 95.
//
const
  LINE_LEN = 256;                 // Win95-compatible maximum for displayable
  {$EXTERNALSYM LINE_LEN}
                                  // strings coming from a device INF.
  MAX_INF_STRING_LENGTH = 4096;   // Actual maximum size of an INF string
  {$EXTERNALSYM MAX_INF_STRING_LENGTH}
                                  // (including string substitutions).
  MAX_TITLE_LEN         = 60;
  {$EXTERNALSYM MAX_TITLE_LEN}
  MAX_INSTRUCTION_LEN   = 256;
  {$EXTERNALSYM MAX_INSTRUCTION_LEN}
  MAX_LABEL_LEN         = 30;
  {$EXTERNALSYM MAX_LABEL_LEN}
  MAX_SERVICE_NAME_LEN  = 256;
  {$EXTERNALSYM MAX_SERVICE_NAME_LEN}
  MAX_SUBTITLE_LEN      = 256;
  {$EXTERNALSYM MAX_SUBTITLE_LEN}

//
// Define maximum length of a machine name in the format expected by ConfigMgr32
// CM_Connect_Machine (i.e., "\\\\MachineName\0").
//

  SP_MAX_MACHINENAME_LENGTH = MAX_PATH + 3;
  {$EXTERNALSYM SP_MAX_MACHINENAME_LENGTH}

//
// Define type for reference to loaded inf file
//

type
  HINF = Pointer;
  {$EXTERNALSYM HINF}

//
// Inf context structure. Applications must not interpret or
// overwrite values in these structures.
//
  PInfContext = ^TInfContext;
  INFCONTEXT = packed record
    Inf: Pointer;
    CurrentInf: Pointer;
    Section: UINT;
    Line: UINT;
  end;
  {$EXTERNALSYM INFCONTEXT}
  TInfContext = INFCONTEXT;

//
// Inf file information structure.
//
  PSPInfInformation = ^TSPInfInformation;
  SP_INF_INFORMATION = packed record
    InfStyle: DWORD;
    InfCount: DWORD;
    VersionData: array [0..ANYSIZE_ARRAY - 1] of Byte;
  end;
  {$EXTERNALSYM SP_INF_INFORMATION}
  TSPInfInformation = SP_INF_INFORMATION;

//
// Define structure for passing alternate platform info into
// SetupSetFileQueueAlternatePlatform and SetupQueryInfOriginalFileInformation.
//
  PSPAltPlatformInfoV2 = ^SP_ALTPLATFORM_INFO_V2;
  SP_ALTPLATFORM_INFO_V2 = packed record
    cbSize: DWORD;
    //
    // platform to use (VER_PLATFORM_WIN32_WINDOWS or VER_PLATFORM_WIN32_NT)
    //
    Platform: DWORD;
    //
    // major and minor version numbers to use
    //
    MajorVersion: DWORD;
    MinorVersion: DWORD;
    //
    // processor architecture to use (PROCESSOR_ARCHITECTURE_INTEL,
    // PROCESSOR_ARCHITECTURE_ALPHA, PROCESSOR_ARCHITECTURE_IA64, or
    // PROCESSOR_ARCHITECTURE_ALPHA64)
    //
    ProcessorArchitecture: WORD;

    Flags: WORD;
    (*
    union {
        WORD  Reserved; // for compatibility with V1 structure
        WORD  Flags;    // indicates validity of non V1 fields
    };
    *)

    //
    // specify SP_ALTPLATFORM_FLAGS_VERSION_RANGE in Flags
    // to use FirstValidatedMajorVersion and FirstValidatedMinorVersion
    //
    // Major and minor versions of the oldest previous OS for which this
    // package's digital signature may be considered valid.  For example, say
    // the alternate platform is VER_PLATFORM_WIN32_NT, version 5.1.  However,
    // it is wished that driver packages signed with a 5.0 osattr also be
    // considered valid.  In this case, you'd have a  MajorVersion/MinorVersion
    // of 5.1, and a FirstValidatedMajorVersion/FirstValidatedMinorVersion of
    // 5.0.  To validate packages signed for any previous OS release, specify
    // 0 for these fields.  To only validate against the target alternate
    // platform, specify the same values as those in the MajorVersion and
    // MinorVersion fields.
    //
    FirstValidatedMajorVersion: DWORD;
    FirstValidatedMinorVersion: DWORD;
  end;
  {$EXTERNALSYM SP_ALTPLATFORM_INFO_V2}
  TSPAltPlatformInfoV2 = SP_ALTPLATFORM_INFO_V2;

  PSPAltPlatformInfoV1 = ^TSPAltPlatformInfoV1;
  SP_ALTPLATFORM_INFO_V1 = packed record
    cbSize: DWORD;
    //
    // platform to use (VER_PLATFORM_WIN32_WINDOWS or VER_PLATFORM_WIN32_NT)
    //
    Platform: DWORD;
    //
    // major and minor version numbers to use
    //
    MajorVersion: DWORD;
    MinorVersion: DWORD;
    //
    // processor architecture to use (PROCESSOR_ARCHITECTURE_INTEL,
    // PROCESSOR_ARCHITECTURE_ALPHA, PROCESSOR_ARCHITECTURE_IA64, or
    // PROCESSOR_ARCHITECTURE_ALPHA64)
    //
    ProcessorArchitecture: Word;
    Reserved: Word; // must be zero.
  end;
  {$EXTERNALSYM SP_ALTPLATFORM_INFO_V1}
  TSPAltPlatformInfoV1 = SP_ALTPLATFORM_INFO_V1;

  {$IFDEF WINXP_UP}
  PSPAltPlatformInfo = PSPAltPlatformInfoV2;
  TSPAltPlatformInfo = TSPAltPlatformInfoV2;
  {$ELSE}
  PSPAltPlatformInfo = PSPAltPlatformInfoV1;
  TSPAltPlatformInfo = TSPAltPlatformInfoV1;
  {$ENDIF WINXP_UP}

//
// the following flags are available to SP_ALTPLATFORM_INFO_V2
//
const
  SP_ALTPLATFORM_FLAGS_VERSION_RANGE = $0001;  // FirstValidatedMajor/MinorVersion
  {$EXTERNALSYM SP_ALTPLATFORM_FLAGS_VERSION_RANGE}

//
// Define structure that is filled in by SetupQueryInfOriginalFileInformation
// to indicate the INF's original name and the original name of the (potentially
// platform-specific) catalog file specified by that INF.
//
type
  PSPOriginalFileInfoA = ^TSPOriginalFileInfoA;
  PSPOriginalFileInfoW = ^TSPOriginalFileInfoW;
  SP_ORIGINAL_FILE_INFO_A = packed record
    cbSize: DWORD;
    OriginalInfName: array [0..MAX_PATH - 1] of AnsiChar;
    OriginalCatalogName: array [0..MAX_PATH - 1] of AnsiChar;
  end;
  {$EXTERNALSYM SP_ORIGINAL_FILE_INFO_A}
  SP_ORIGINAL_FILE_INFO_W = packed record
    cbSize: DWORD;
    OriginalInfName: array [0..MAX_PATH - 1] of WideChar;
    OriginalCatalogName: array [0..MAX_PATH - 1] of WideChar;
  end;
  {$EXTERNALSYM SP_ORIGINAL_FILE_INFO_W}
  TSPOriginalFileInfoA = SP_ORIGINAL_FILE_INFO_A;
  TSPOriginalFileInfoW = SP_ORIGINAL_FILE_INFO_W;
  {$IFDEF UNICODE}
  PSPOriginalFileInfo = PSPOriginalFileInfoW;
  TSPOriginalFileInfo = TSPOriginalFileInfoW;
  {$ELSE}
  TSPOriginalFileInfo = TSPOriginalFileInfoA;
  PSPOriginalFileInfo = PSPOriginalFileInfoA;
  {$ENDIF UNICODE}

//
// SP_INF_INFORMATION.InfStyle values
//
const
  INF_STYLE_NONE  = $00000000; // unrecognized or non-existent
  {$EXTERNALSYM INF_STYLE_NONE}
  INF_STYLE_OLDNT = $00000001; // winnt 3.x
  {$EXTERNALSYM INF_STYLE_OLDNT}
  INF_STYLE_WIN4  = $00000002; // Win95
  {$EXTERNALSYM INF_STYLE_WIN4}

//
// Additional InfStyle flags that may be specified when calling SetupOpenInfFile.
//
//
  INF_STYLE_CACHE_ENABLE  = $00000010; // always cache INF, even outside of %windir%\Inf
  {$EXTERNALSYM INF_STYLE_CACHE_ENABLE}
  INF_STYLE_CACHE_DISABLE = $00000020; // delete cached INF information
  {$EXTERNALSYM INF_STYLE_CACHE_DISABLE}

//
// Target directory specs.
//
  DIRID_ABSOLUTE       = DWORD(-1); // real 32-bit -1
  {$EXTERNALSYM DIRID_ABSOLUTE}
  DIRID_ABSOLUTE_16BIT = $FFFF; // 16-bit -1 for compat w/setupx
  {$EXTERNALSYM DIRID_ABSOLUTE_16BIT}
  DIRID_NULL           = 0;
  {$EXTERNALSYM DIRID_NULL}
  DIRID_SRCPATH        = 1;
  {$EXTERNALSYM DIRID_SRCPATH}
  DIRID_WINDOWS        = 10;
  {$EXTERNALSYM DIRID_WINDOWS}
  DIRID_SYSTEM         = 11; // system32
  {$EXTERNALSYM DIRID_SYSTEM}
  DIRID_DRIVERS        = 12;
  {$EXTERNALSYM DIRID_DRIVERS}
  DIRID_IOSUBSYS       = DIRID_DRIVERS;
  {$EXTERNALSYM DIRID_IOSUBSYS}
  DIRID_INF            = 17;
  {$EXTERNALSYM DIRID_INF}
  DIRID_HELP           = 18;
  {$EXTERNALSYM DIRID_HELP}
  DIRID_FONTS          = 20;
  {$EXTERNALSYM DIRID_FONTS}
  DIRID_VIEWERS        = 21;
  {$EXTERNALSYM DIRID_VIEWERS}
  DIRID_COLOR          = 23;
  {$EXTERNALSYM DIRID_COLOR}
  DIRID_APPS           = 24;
  {$EXTERNALSYM DIRID_APPS}
  DIRID_SHARED         = 25;
  {$EXTERNALSYM DIRID_SHARED}
  DIRID_BOOT           = 30;
  {$EXTERNALSYM DIRID_BOOT}

  DIRID_SYSTEM16       = 50;
  {$EXTERNALSYM DIRID_SYSTEM16}
  DIRID_SPOOL          = 51;
  {$EXTERNALSYM DIRID_SPOOL}
  DIRID_SPOOLDRIVERS   = 52;
  {$EXTERNALSYM DIRID_SPOOLDRIVERS}
  DIRID_USERPROFILE    = 53;
  {$EXTERNALSYM DIRID_USERPROFILE}
  DIRID_LOADER         = 54;
  {$EXTERNALSYM DIRID_LOADER}
  DIRID_PRINTPROCESSOR = 55;
  {$EXTERNALSYM DIRID_PRINTPROCESSOR}

  DIRID_DEFAULT        = DIRID_SYSTEM;
  {$EXTERNALSYM DIRID_DEFAULT}

//
// The following DIRIDs are for commonly-used shell "special folders".  The
// complete list of such folders is contained in shlobj.h.  In that headerfile,
// each folder is assigned a CSIDL_* value.  The DIRID values below are created
// by taking the CSIDL value in shlobj.h and OR'ing it with 0x4000.  Thus, if
// an INF needs to reference other special folders not defined below, it may
// generate one using the above mechanism, and setupapi will automatically deal
// with it and use the corresponding shell's path where appropriate.  (Remember
// that DIRIDs must be specified in decimal, not hex, in an INF when used for
// string substitution.)
//
  DIRID_COMMON_STARTMENU        = 16406; // All Users\Start Menu
  {$EXTERNALSYM DIRID_COMMON_STARTMENU}
  DIRID_COMMON_PROGRAMS         = 16407; // All Users\Start Menu\Programs
  {$EXTERNALSYM DIRID_COMMON_PROGRAMS}
  DIRID_COMMON_STARTUP          = 16408; // All Users\Start Menu\Programs\Startup
  {$EXTERNALSYM DIRID_COMMON_STARTUP}
  DIRID_COMMON_DESKTOPDIRECTORY = 16409; // All Users\Desktop
  {$EXTERNALSYM DIRID_COMMON_DESKTOPDIRECTORY}
  DIRID_COMMON_FAVORITES        = 16415; // All Users\Favorites
  {$EXTERNALSYM DIRID_COMMON_FAVORITES}
  DIRID_COMMON_APPDATA          = 16419; // All Users\Application Data
  {$EXTERNALSYM DIRID_COMMON_APPDATA}

  DIRID_PROGRAM_FILES           = 16422; // Program Files
  {$EXTERNALSYM DIRID_PROGRAM_FILES}
  DIRID_SYSTEM_X86              = 16425; // system32 on RISC
  {$EXTERNALSYM DIRID_SYSTEM_X86}
  DIRID_PROGRAM_FILES_X86       = 16426; // Program Files on RISC
  {$EXTERNALSYM DIRID_PROGRAM_FILES_X86}
  DIRID_PROGRAM_FILES_COMMON    = 16427; // Program Files\Common
  {$EXTERNALSYM DIRID_PROGRAM_FILES_COMMON}
  DIRID_PROGRAM_FILES_COMMONX86 = 16428; // x86 Program Files\Common on RISC
  {$EXTERNALSYM DIRID_PROGRAM_FILES_COMMONX86}

  DIRID_COMMON_TEMPLATES        = 16429; // All Users\Templates
  {$EXTERNALSYM DIRID_COMMON_TEMPLATES}
  DIRID_COMMON_DOCUMENTS        = 16430; // All Users\Documents

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -