|
[求助]用CreateProcess执行一个外部卸载程序,如何知道用户卸载成功了还是中途取消卸载了呢?
我的是XP SP3,确实不太好实现,想到一个办法来实现:通过判断注册表项是否还存在来决定是否已经卸载掉了. void CSoftXiezaiInfoDialog::OnBnClickedButtonUnstall() { // TODO: 在此添加控件通知处理程序代码 CString m_exefilePath=m_unstallString; //创建卸载进程 if(!CreateProcess(NULL,(LPTSTR)(LPCTSTR)m_exefilePath,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&si,&pi)) { MessageBox(_T("创建进程失败!")); return; } else { WaitForSingleObject(pi.hProcess,INFINITE); GetExitCodeProcess(pi.hProcess,&dwExitCode); CloseHandle(pi.hProcess); CloseHandle(pi.hThread); //判断此软件名在注册表中的项还存在否 //需要根据软件名找到他的注册表对应的项 GetDlgItemText(IDC_XIEZAI_NAME,m_softName); map<CString,CString>::iterator iter_map=CSoftXiezaiTypeListDialog::m_softnameregeditmap.find(m_softName); if(iter_map!=CSoftXiezaiTypeListDialog::m_softnameregeditmap.end()) { m_regeditString=(*iter_map).second; } CString m_regeditStringTemp=_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\")+m_regeditString; HKEY hKey; if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,m_regeditStringTemp,NULL,KEY_ALL_ACCESS,&hKey)==ERROR_SUCCESS) { //此项还在表明没有执行卸载可能是点击的取消等,不需要做任何改变 } else { //此项已经不在表明执行了卸载了,需要刷新子控件 m_UnstallButton.SetText(_T("已卸载"),RGB(51,51,51)); m_UnstallButton.Invalidate(); } } } 不晓得还有没有其他方式,也不晓得360,QQ等那些软件管家是如何实现此处的。。。 |
|
[求助]用CreateProcess执行一个外部卸载程序,如何知道用户卸载成功了还是中途取消卸载了呢?
正如楼上所说那样,很多卸载程序的exitcode返回值很奇葩,从返回值可能判断一些,但很多都不适用的,曾几何时也想过检测卸载程序是否还存在来看是否卸载。。。。然而有些卸载参数或命令并非单纯的c:\program....\unstall.exe类似这样,而是比较蛋疼的MsiExec.exe /X{052CFB79------} 所以想不到什么好的方法,但是OS自带的添加或删除程序,360的软件管家等这些软件是如何实现的呢?求指导。。。 |
|
[求助]Run-Time check failure #2 stack around the variable 'regData' was corrupted该如何解决?
YZ兄,我顺便罗嗦一句吧:本身是读取注册表中的信息来得到图标的获取方法,读取的注册表项为 SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Management\\ARPCache"里面的每个SlowInfoCache子项,这个子项的内容有些特殊,前面28个byte表示的貌似是大小之类的信息,从第29个byte开始是程序的路径了(见图片),因此你上面的代码我进行了修改,使得可以正确显示出来图标。 if (lResult == ERROR_SUCCESS) { WCHAR *szData=(WCHAR*)malloc(dwSize*sizeof(WCHAR)+2); ZeroMemory(szData,dwSize*sizeof(WCHAR)); lResult = RegQueryValueEx(hKey, szValue2, NULL, &dwType2, (LPBYTE)szData, &dwSize); if (lResult == ERROR_SUCCESS) { if(szData!=NULL){ ExtractIconExW(szData+14, 0, &hIcon, NULL, 1); } } } RegCloseKey(hKey); 由于你用的WCHAR,因此这里偏移是28/2=14,这样可以取得正确图标了。。 |
|
|
|
[求助]Run-Time check failure #2 stack around the variable 'regData' was corrupted该如何解决?
if (hIcon == NULL) { 知道问题是在这块,但是真心找不出来。。。。悲哀。 |
|
|
|
[讨论]请问软件管家中是如何得到软件图标跟使用频率的呢?
看样子是沉了 |
|
[求助]MFC中这样的数据跟界面之间的关系该如何处理?
为何?理由是? |
|
[求助]关于无法删除文件的一个疑问
是不是这个文件在这个进程中的引用次数导致的?如果引用次数为1你CloseHandle()一次就能删除了,如果被这个进程引用次数超过1次,那你是如何确保你完全关闭次文件句柄的? |
|
[原创]VC/MFC中翻页控件实现
哦,怪抱歉的,以为代码放上去过了。。。。。非常对不起大家,完整工程已经再次上传 |
|
|
|
[求助]MFC中这样的数据跟界面之间的关系该如何处理?
[QUOTE=xiejienet;1094231]最好是把整个主窗口的this指针作为worker thread的参数,在worker thread里填充接收到的信息[比如存放到主窗口的一个Public变量里],下载完毕后,发消息回去,通知主窗口创建控件,显示信息......[/QUOTE] 三克油,目前就是用的这个方式,开个线程来读取数据,读取完毕后通知对话框(PostMessage)然后在消息中创建对话框来完成数据显示操作,这里仍然不能够让人满意,假如数据有100条甚至更多的情况,此时创建100来个控件来显示数据,包括控制控件的位置等繁琐的操作都会有些耗时,会显的稍微有点点卡(当控件显示数据的那个时刻),请问这里有没有什么解决办法? 我想过另开一个线程来处理创建控件,显示读取到的数据。。。。然而在MFC中用AfxBeginThread创建线程,在线程中创建控件总是发生断言失败,也查询了一些资料,没有找到更加好的方法。。。 |
|
[原创]VC/MFC中翻页控件实现
VS08,肿么了,亲 |
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值