列出Win32设备命名空间的内容

时间:2016-03-24 11:29:18

标签: c++ windows winapi namespaces device

来自microsoft-doku:

  

var myApp = angular.module('myApp', []); myApp.controller("MyCtrl", function ($scope) { var tThis = this; $scope.dataTypeList = [{ 'id' : 1, "label" : "Currency" }, { 'id' : 2, "label" : "Number" }, { 'id' : 3, "label" : "Text" } ]; $scope.dataTypeValue; $scope.textValue $scope.customPattern = ''; $scope.className = "ng-invalid ng-invalid-pattern" $scope.setCustomPattern = function () { var dataTypeId = $scope.dataTypeValue.id; console.log(dataTypeId + 'llsdkfalskdf'); if (dataTypeId === 1) { $scope.customPattern = /^\d{1,10}$/; } else if (dataTypeId === 2) { $scope.customPattern = /^\d+$/; } else if (dataTypeId === 3) { $scope.customPattern = /^.*$/; } return $scope.customPattern }; $scope.$watch("[dataTypeValue, textValue]", function (nw, old) { var s = $('input[name=input]').val() $scope.textValue = s; var pattern = $scope.setCustomPattern() if (pattern.test($scope.textValue)) { $scope.className = "ng-valid ng-valid-pattern" } else { $scope.className = "ng-invalid ng-invalid-pattern" } }); }); 前缀将访问Win32设备名称空间而不是   Win32文件命名空间。这是如何访问物理磁盘和   卷直接完成,无需通过文件   系统,如果API支持这种类型的访问。你可以访问很多   这种方式以外的设备(使用CreateFile和   例如,DefineDosDevice函数。

     

例如,如果要打开系统的串行通信   端口1,您可以在调用CreateFile函数时使用“COM1”。   这是有效的,因为COM1-COM9是NT中保留名称的一部分   命名空间,尽管使用"\\.\"前缀也可以使用这些   设备名称。

我的问题是,此命名空间中提供了什么。是否有设备列表,我在哪里可以获得它? (我想我不明白这个话题。当我听到设备时,我会想到某个目录中的某种文件。)

编辑:

好的,我会回答我自己的问题。有一个名为WinObj的软件,可以用来查看信息。

2 个答案:

答案 0 :(得分:0)

好的,我会回答我自己的问题。有一个名为WinObj的软件,可以用来查看信息。

答案 1 :(得分:0)

您可以使用QueryDosDevice Win32 API调用来获取所有Win32设备名称。

#include <windows.h>
#include <stdio.h>

#define DEVBUFSIZ (128 * 1024)      /* No recommended value - ~14K for me */
int main(int argc, char** argv)
{
    wchar_t devicenames[DEVBUFSIZ]  = L"";
    int     error                   = 0;
    int     wchar_count             = 0;

    wchar_count = QueryDosDeviceW(
            NULL,       /* lpDeviceName - NULL gives all */
            devicenames,
            DEVBUFSIZ);
    if (wchar_count == 0) {
        fprintf(stderr, "QueryDosDeviceW failed with error code %d\n", error);
        return 1;
    }
    for (int i = 0; i < wchar_count; i++) {
        if (devicenames[i] == '\0')
            devicenames[i] = '\n';
    }
    wprintf(L"%s", devicenames);
    return 0;
}

另外,WinObj主要不列出Win32设备名称,它列出了Windows NT对象名称。尽管可以在WinObj中的GLOBAL??节点下找到Win32设备名称。

参见&#34;更多信息&#34;在https://support.microsoft.com/en-us/kb/100027