码迷,mamicode.com
首页 > Windows程序 > 详细

Windows7,程序兼容助手:这个程序可能安装不正确(做注册表里设置白名单,软件自身的名字不能带setup)

时间:2017-07-22 00:10:46      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:mod   ext   appcompat   函数   hbm   filename   文件   eof   targe   

Windows上有一个很奇怪的一个现象,一个exe只要名字里面带了setup\install之类的,打开exe后立即退出就会弹出下面的窗口。

技术分享

解决方法:

方法一、更改exe的名字,去掉setup\install,即使是资源文件rc中的setup\install也要去掉。

方法二、在main函数入口处调用下面的函数,将当前exe写入Windows的“注册表白名单”中去,关闭时Windows就不会弹出兼容助手了。

 

[cpp] view plain copy
 
  1. bool RegWritePca()    
  2. {    
  3.     HKEY hKey;    
  4.     if (ERROR_SUCCESS != RegOpenKeyEx(HKEY_CURRENT_USER,    
  5.         L"Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Compatibility Assistant\\Persisted", 0, KEY_READ | KEY_WRITE, &hKey))    
  6.     {    
  7.         return false;    
  8.     }    
  9.     wchar_t szPath[MAX_PATH];    
  10.     GetModuleFileName(NULL, szPath, MAX_PATH);    
  11.     DWORD dwCode = 1;    
  12.     LONG lRet = RegSetValueEx(hKey, szPath, 0, REG_DWORD, (byte*)&dwCode, sizeof(DWORD));    
  13.     RegCloseKey(hKey);    
  14.     return lRet == ERROR_SUCCESS;    
  15. }    


参考链接:http://blog.csdn.net/mfcing/article/details/52087704

 

http://blog.csdn.net/caoshangpa/article/details/72235939

Windows7,程序兼容助手:这个程序可能安装不正确(做注册表里设置白名单,软件自身的名字不能带setup)

标签:mod   ext   appcompat   函数   hbm   filename   文件   eof   targe   

原文地址:http://www.cnblogs.com/findumars/p/7220067.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!