#include <QtCore>#include <windows.h>int main(int argc, char *argv[]){ QCoreApplication app(argc, argv); OSVERSIONINFO osvi; osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if (!(GetVersionEx(&osvi) && (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT))) { qDebug() << "Error OS type"; return 0; } // CHAR res[65535]; DWORD retval=QueryDosDeviceA("COM1", res, 65535); QString tmp = QString("retval : %1").arg(retval); qDebug() << tmp; qDebug() << res; return app.exec();}
On Error Resume NextSet objService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\CIMV2")If Err.Number <> 0 Then WScript.Echo Err.Number & ": " & Err.Description WScript.QuitEnd IfFor Each objPort In objService.ExecQuery("SELECT * FROM Win32_SerialPort") WScript.Echo objPort.Caption 'наименование устройства WScript.Echo objPort.Description 'описание устройства WScript.Echo objPort.DeviceID 'идентификатор устройства WScript.Echo objPort.PNPDeviceID 'идентификатор устройства Plug-and-Play WScript.Echo objPort.SystemName 'имя компьютера WScript.EchoNext
#include <QtCore>int main(int argc, char *argv[]){ QCoreApplication app(argc, argv); QSettings settings("HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\SERIALCOMM",QSettings::NativeFormat); QString port = settings.value("\Device\Serial0").toString(); // <--- ЭТО строка №11 qDebug() << port; return app.exec();}
.. qDebug() << settings.allKeys();..
/*\en \ru */#include <QtCore>#include <windows.h>int main(int argc, char *argv[]){ QCoreApplication app(argc, argv); LONG retVal=0; DWORD Index=0; DWORD dwTypeCode; char KeyParam[256]; char KeyValue[256]; DWORD dwKeyParamLength = sizeof(KeyParam); DWORD dwKeyValueLength = sizeof(KeyValue); LONG lnResult; HKEY hKey; retVal=RegOpenKeyExA(HKEY_LOCAL_MACHINE,"Hardware\\Devicemap\\Serialcomm", 0, KEY_READ, &hKey); qDebug() << "RegOpenKeyExA =" << retVal; while (RegEnumValueA(hKey, Index, KeyParam, &dwKeyParamLength, NULL, &dwTypeCode, (BYTE *)KeyValue, &dwKeyValueLength) == ERROR_SUCCESS) { if(dwTypeCode == REG_SZ) { qDebug() << "Index=" << Index; qDebug() << "KeyParam=" << KeyParam; qDebug() << "dwKeyParamLength=" << dwKeyParamLength; qDebug() << "dwTypeCode=" << dwTypeCode; qDebug() << "KeyValue=" << KeyValue; qDebug() << "dwKeyValueLength=" << dwKeyValueLength; } ++Index; dwKeyParamLength = sizeof(KeyParam); dwKeyValueLength = sizeof(KeyValue); } retVal=RegCloseKey(hKey); qDebug() << "RegCloseKey=" << retVal; return app.exec();}