Skip to content

QueryResult API

The query module provides a structured API for querying installed MSVC and Windows SDK components.

Core Types

QueryOptions

Configuration for a query operation.

rust
use msvc_kit::query::{QueryOptions, QueryComponent, QueryProperty};
use msvc_kit::Architecture;

let options = QueryOptions::builder()
    .install_dir("C:/msvc-kit")
    .arch(Architecture::X64)
    .component(QueryComponent::All)
    .property(QueryProperty::All)
    .msvc_version("14.44")
    .sdk_version("10.0.26100.0")
    .build();
FieldTypeDefaultDescription
install_dirPathBuf"msvc-kit"Installation directory to query
archArchitectureHost archTarget architecture
componentQueryComponentAllWhich component to query
propertyQueryPropertyAllWhat property to retrieve
msvc_versionOption<String>NoneSpecific MSVC version (None = latest)
sdk_versionOption<String>NoneSpecific SDK version (None = latest)

QueryComponent

rust
pub enum QueryComponent {
    All,   // Query both MSVC and SDK
    Msvc,  // Query only MSVC compiler
    Sdk,   // Query only Windows SDK
}

Parsed from strings: "all", "msvc", "sdk", "winsdk"

QueryProperty

rust
pub enum QueryProperty {
    All,      // Return all information
    Path,     // Installation paths
    Env,      // Environment variables
    Tools,    // Tool executable paths
    Version,  // Version information
    Include,  // Include paths
    Lib,      // Library paths
}

Parsed from strings with aliases:

  • "path" / "paths" / "install-path"
  • "env" / "environment" / "env-vars"
  • "tools" / "tool" / "executables"
  • "version" / "versions" / "ver"
  • "include" / "includes" / "include-paths"
  • "lib" / "libs" / "lib-paths"

QueryResult

The result of a query operation, containing all discovered information.

rust
pub struct QueryResult {
    pub install_dir: PathBuf,
    pub arch: String,
    pub msvc: Option<ComponentInfo>,
    pub sdk: Option<ComponentInfo>,
    pub env_vars: HashMap<String, String>,
    pub tools: HashMap<String, PathBuf>,
}

Methods

MethodReturn TypeDescription
tool_path(name)Option<&PathBuf>Get path to a specific tool
env_var(name)Option<&String>Get a specific environment variable
msvc_version()Option<&str>Get MSVC version string
sdk_version()Option<&str>Get SDK version string
msvc_install_path()Option<&Path>Get MSVC installation path
sdk_install_path()Option<&Path>Get SDK installation path
all_include_paths()Vec<&PathBuf>Get all include paths
all_lib_paths()Vec<&PathBuf>Get all library paths
to_json()serde_json::ValueExport as JSON
format_summary()StringHuman-readable summary

ComponentInfo

Information about a single installed component.

rust
pub struct ComponentInfo {
    pub component_type: String,
    pub version: String,
    pub install_path: PathBuf,
    pub include_paths: Vec<PathBuf>,
    pub lib_paths: Vec<PathBuf>,
    pub bin_paths: Vec<PathBuf>,
}

Functions

query_installation

rust
pub fn query_installation(options: &QueryOptions) -> Result<QueryResult>

Query an existing installation for component information.

Example:

rust
use msvc_kit::query::{QueryOptions, query_installation};

let options = QueryOptions::builder()
    .install_dir("C:/msvc-kit")
    .build();

let result = query_installation(&options)?;

// Get cl.exe path
if let Some(cl) = result.tool_path("cl") {
    println!("cl.exe: {}", cl.display());
}

// Get all environment variables
for (key, value) in &result.env_vars {
    println!("{}={}", key, value);
}

Available Tools

The following tool names can be queried via tool_path():

NameExecutableDescription
clcl.exeC/C++ compiler
linklink.exeLinker
liblib.exeStatic library manager
ml64ml64.exeMASM assembler (x64)
nmakenmake.exeMake utility
rcrc.exeResource compiler
mtmt.exeManifest tool
dumpbindumpbin.exeBinary file dumper
editbineditbin.exeBinary file editor

Environment Variables

The env_vars field contains these standard variables:

VariableExample
INCLUDEC:\msvc-kit\VC\Tools\MSVC\14.44\include;...
LIBC:\msvc-kit\VC\Tools\MSVC\14.44\lib\x64;...
PATHC:\msvc-kit\VC\Tools\MSVC\14.44\bin\Hostx64\x64;...
VCToolsVersion14.44.34823
VCToolsInstallDirC:\msvc-kit\VC\Tools\MSVC\14.44.34823
VCINSTALLDIRC:\msvc-kit\VC
WindowsSdkDirC:\msvc-kit\Windows Kits\10
WindowsSDKVersion10.0.26100.0\
WindowsSdkBinPathC:\msvc-kit\Windows Kits\10\bin\10.0.26100.0
Platformx64

Released under the MIT License.