Open utterances-bot opened 2 years ago
“C++ 版判断方法 挖个坑,明天更新……” 😂 刚刚想看大佬怎么用C++实现,发现了这个。 我有一个应用现在正在使用NET 6,但是也要求对Windows 7 SP0做支持。现在我的处理办法是自己写一个AppHost...
using namespace std; //不显示控制台
const wchar_t accStr = L"启动自己的exe"; const wchar_t installStr = L"安装补丁的脚本";
int main() { HMODULE hMoudule = GetModuleHandle(L"kernel32.dll");
if (hMoudule) {
DWORD handle = (DWORD)GetProcAddress(hMoudule, "AddDllDirectory");
if (handle != 0) {
printf("Either running on Win8+, or KB2533623 is installed");
if (_waccess(accStr, 0) == 0) {
SHELLEXECUTEINFO ShExecInfo = { 0 };
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = L"runas";
ShExecInfo.lpFile = L"op.exe";
ShExecInfo.lpParameters = L"";
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
}
else {
printf("not found acc");
}
}
else {
printf("Likely running on Win7 or older OS, and KB2533623 is not installed");
if (_waccess(installStr, 0) == 0) {
SHELLEXECUTEINFO ShExecInfo = { 0 };
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = L"runas";
ShExecInfo.lpFile = L"installpack.bat";
ShExecInfo.lpParameters = L"";
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
if (ShExecInfo.hProcess!=NULL) {
WaitForSingleObject(ShExecInfo.hProcess, INFINITE);
}
MessageBox(NULL, L"修补完成请重启电脑", L"提示", MB_OK);
}
else {
printf("not found installpack");
}
}
}
}
坑我帮你填了
https://github.com/RA3CoronaDevelopers/WinNetHost 我们也实现了一个,不过还没写完2333
还要检测 .net 运行库安装么 现在不是有独立发布么 压缩成安装包 大小也就70m左右我觉得可以接受啊
@.***
From: MrBBBaiXue Date: 2022-12-14 18:40 To: walterlv/BlogComments CC: dongzhaosheng73; Comment Subject: Re: [walterlv/BlogComments] post/how-to-detect-system-supports-dotnet (Issue #124) https://github.com/RA3CoronaDevelopers/WinNetHost 我们也实现了一个,不过还没写完2333 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>
如何检测当前操作系统是否支持运行 .NET Core 3 / .NET 5 / .NET 6 应用? - walterlv
虽然微软官方声称 .NET Core 3 / .NET 5 / .NET 6 应用支持在 Windows 7 及以上运行,但你不应该轻信。因为微软还在某个隐秘的角落里说明还应安装一枚 KB2533623 补丁。 直接判断补丁肯定是不靠谱的,因为还有其他几枚补丁(KB3063858、KB4457144)包含了这枚补丁。所以有没有什
https://blog.walterlv.com/post/how-to-detect-system-supports-dotnet