你可以用 wmic 获得 你的 系统,设备,进程。。。方面的信息。拍 wmic /? 可得帮助信息 (很多,很繁杂)
程序里用 system() 调用,把输出转向到文件,然后处理文件,得到需要的信息。
例如串行口:
system("wmic path Win32_SerialPort >> alog");
打印机命令
WMIC PRINTER LIST
WMIC PRINTER where PortName="LPT1:" GET PortName, Name, ShareName
盘的命令
wmic logicaldisk get namewmic diskdrive get model,name,size
Java代码
// android获取短信所有内容
// 注意设置权限[添加到AndroidMainfestxml] <uses-permission android:name="androidpermissionREAD_SMS" />
public String getSmsInPhone()
{
final String SMS_URI_ALL = "content://sms/";
final String SMS_URI_INBOX = "content://sms/inbox";
final String SMS_URI_SEND = "content://sms/sent";
final String SMS_URI_DRAFT = "content://sms/draft";
StringBuilder smsBuilder = new StringBuilder();
try{
ContentResolver cr = getContentResolver();
String[] projection = new String[]{"_id", "address", "person",
"body", "date", "type"};
Uri uri = Uriparse(SMS_URI_ALL);
Cursor cur = crquery(uri, projection, null, null, "date desc");
if (curmoveToFirst()) {
String name;
String phoneNumber;
String smsbody;
String date;
String type;
int nameColumn = curgetColumnIndex("person");
int phoneNumberColumn = curgetColumnIndex("address");
int smsbodyColumn = curgetColumnIndex("body");
int dateColumn = curgetColumnIndex("date");
int typeColumn = curgetColumnIndex("type");
do{
name = curgetString(nameColumn);
phoneNumber = curgetString(phoneNumberColumn);
smsbody = curgetString(smsbodyColumn);
SimpleDateFormat dateFormat = new SimpleDateFormat(
"yyyy-MM-dd hh:mm:ss");
Date d = new Date(LongparseLong(curgetString(dateColumn)));
date = dateFormatformat(d);
int typeId = curgetInt(typeColumn);
if(typeId == 1){
type = "接收";
} else if(typeId == 2){
type = "发送";
} else {
type = "";
}
smsBuilderappend("[");
smsBuilderappend(name+",");
smsBuilderappend(phoneNumber+",");
smsBuilderappend(smsbody+",");
smsBuilderappend(date+",");
smsBuilderappend(type);
smsBuilderappend("] ");
if(smsbody == null) smsbody = "";
}while(curmoveToNext());
} else {
smsBuilderappend("no result!");
}
smsBuilderappend("getSmsInPhone has executed!");
} catch(SQLiteException ex) {
Logd("SQLiteException in getSmsInPhone", exgetMessage());
}
return smsBuildertoString();
}
以上就是关于如何使用 Windows API 从串口读取对方一次发送的任意长度的信息全部的内容,包括:如何使用 Windows API 从串口读取对方一次发送的任意长度的信息、android开发怎样获取系统短信指定内容求大神啊!、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)