user-0 提问: 用C语言实现，通过com端口的名字，获得com端口序号，（如com1,com2……）

回复:
user: user-1
content: 引用 9 楼 zhao4zhong1 的回复:其实最应该得分的是7楼。 C:\>devcon /? Device Console Help: devcon [-r] [-m:\\<machine>] <command> [<arg>...] -r if specified will reboot machine after command is complete, if needed. <machine> is name of target machine. <command> is command to perform (see below). <arg>... is one or more arguments if required by command. For help on a specific command, type: devcon help <command> classfilter          Allows modification of class filters. classes              List all device setup classes. disable              Disable devices that match the specific hardware or instance ID. driverfiles          List driver files installed for devices. drivernodes          Lists all the driver nodes of devices. enable               Enable devices that match the specific hardware or instance ID. find                 Find devices that match the specific hardware or instance ID. findall              Find devices including those that are not present. help                 Display this information. hwids                Lists hardware ID's of devices. install              Manually install a device. listclass            List all devices for a setup class. reboot               Reboot local machine. remove               Remove devices that match the specific hardware or instance ID. rescan               Scan for new hardware. resources            Lists hardware resources of devices. restart              Restart devices that match the specific hardware or instance ID. sethwid              Modify Hardware ID's of listed root-enumerated devices. stack                Lists expected driver stack of devices. status               List running status of devices. update               Manually update a device. updateni             Manually update a device (non interactive).

user: user-1
content: 其实最应该得分的是7楼。

user: user-2
content: 看到3楼回复的时候，笑喷了 是我笑点低么 Nice Code!

user: user-1
content: 搜“devcon”

user: user-3
content: http://stackoverflow.com/questions/4061345/how-to-get-the-actual-com-port-number-with-setupdigetdeviceregistryproperty

user: user-4
content: 引用 4 楼 huangai123 的回复:大神，先谢谢你的代码。但是您还是误会了我的意思 目前已知条件只有Inter(R)Active Managerment Technology而不是 Inter(R)Active Managerment Technology（com3），要通过注册表或者其他方式才能或得到，不是简单的字符串处理，如果是简单的字符串处理，我也就没必要发帖了 第一点 问问题不准确 也不专业 我想没人会回答你这个问题的  第二点 只是个大问题按你所说 你认为区区40分这个问题就能用三言俩语解决 第三 上下文环境没有交代清楚 就算是图灵来了也是徒劳的

user: user-0
content: 大神，先谢谢你的代码。但是您还是误会了我的意思 目前已知条件只有Inter(R)Active Managerment Technology而不是 Inter(R)Active Managerment Technology（com3），要通过注册表或者其他方式才能或得到，不是简单的字符串处理，如果是简单的字符串处理，我也就没必要发帖了

user: user-1
content: #include <stdio.h> #include <string.h> char s[]="Inter(R)Active Managerment Technology（com3）"; char COMn[6]; int main() {  if (1==sscanf(s,"Inter(R)Active Managerment Technology（%5[comCOM0123456789]",COMn)) {   printf("[%s]\n",COMn);  } else {   printf("Format Error:[%s]\n",s);  }  return 0; } //[com3] //

user: user-0
content: 你理解错我的问题了 举例说明： 设备管理器里面显示：Inter(R)Active Managerment Technology（com3） 就是通过    Inter(R)Active Managerment Technology 来获取com3;

user: user-1
content: #include <stdio.h> #include <string.h> char comn[]="com16"; char COMn[6]; int comport; int main() {  strncpy(COMn,comn,5);COMn[5]=0;  strupr(COMn);  if (1==sscanf(COMn,"COM%d",&comport)) {   printf("%s is COM port %d\n",comn,comport);  } else {   printf("Format Error:[%s]\n",comn);  }  return 0; }