C++获取Windows密码复杂度、密码有效期、密码锁定阀值等安全策略 |
您所在的位置:网站首页 › windows密码策略修改 › C++获取Windows密码复杂度、密码有效期、密码锁定阀值等安全策略 |
WMI获取安全策略如:密码复杂度、密码锁定阀值、密码有效期等,相当复杂,但通过以下解决办法,很方便的获取到: 1、现在以管理员模式打开的cmd命令行键入看下效果 键入命令为 secedit /export /cfg luan.inf > 0 & type luan.inf | findstr /R /i "^min ^max ^pass ^lock"得到如下图: 以同样的办法可获取到组策略相关的参数如此链接;https://blog.csdn.net/irizhao/article/details/78481529?utm_source=blogxgwz3 2、实际代码中用c++函数调用如下:方法二:以下函数等同于system,但很方便的将获取返回值类型为string。 string getCmdResult(const string &strCmd) { char buf[10240] = { 0 }; FILE *pf = NULL; if ((pf = _popen(strCmd.c_str(), "r")) == NULL) { return ""; } string strResult; while (fgets(buf, sizeof buf, pf)) { strResult += buf; } _pclose(pf); unsigned int iSize = strResult.size(); if (iSize > 0 && strResult[iSize - 1] == '\n') { strResult = strResult.substr(0, iSize - 1); } return strResult; } int main() { string command_rd = "secedit /export /cfg luan.inf > 0 & type luan.inf | findstr /R /i \"^min ^max ^pass ^lock\""; string str; str = getCmdResult(command_rd); cout |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |