convert utf8
This commit is contained in:
@@ -10,3 +10,4 @@ __recovery/
|
|||||||
*.cbpr
|
*.cbpr
|
||||||
*.local
|
*.local
|
||||||
*.rc
|
*.rc
|
||||||
|
*.dsv
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ProjectGuid>{4FDA74F8-059D-4F68-A028-A088D015B63F}</ProjectGuid>
|
<ProjectGuid>{4FDA74F8-059D-4F68-A028-A088D015B63F}</ProjectGuid>
|
||||||
<ProjectVersion>20.4</ProjectVersion>
|
<ProjectVersion>20.5</ProjectVersion>
|
||||||
<FrameworkType>VCL</FrameworkType>
|
<FrameworkType>VCL</FrameworkType>
|
||||||
<AppType>Application</AppType>
|
<AppType>Application</AppType>
|
||||||
<MainSource>AppUpgrade.cpp</MainSource>
|
<MainSource>AppUpgrade.cpp</MainSource>
|
||||||
|
|||||||
+4
-4
@@ -1,4 +1,4 @@
|
|||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
#include <vcl.h>
|
#include <vcl.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
|
||||||
@@ -15,9 +15,9 @@ String MAIN_APP_NAME;
|
|||||||
BOOL ImprovePrivilege()
|
BOOL ImprovePrivilege()
|
||||||
{
|
{
|
||||||
HANDLE token;
|
HANDLE token;
|
||||||
//ÌáÉýȨÏÞ
|
//提升权限
|
||||||
if(!OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES,&token)){
|
if(!OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES,&token)){
|
||||||
MessageBox(NULL,L"´ò¿ª½ø³ÌÁîÅÆÊ§°Ü...",L"´íÎó",MB_ICONSTOP);
|
MessageBox(NULL,L"打开进程令牌失败...",L"错误",MB_ICONSTOP);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ BOOL ImprovePrivilege()
|
|||||||
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||||
|
|
||||||
if(!AdjustTokenPrivileges(token,FALSE,&tkp,sizeof(tkp),NULL,NULL)){
|
if(!AdjustTokenPrivileges(token,FALSE,&tkp,sizeof(tkp),NULL,NULL)){
|
||||||
MessageBox(NULL,L"µ÷ÕûÁîÅÆÈ¨ÏÞʧ°Ü...",L"´íÎó",MB_ICONSTOP);
|
MessageBox(NULL,L"调整令牌权限失败...",L"错误",MB_ICONSTOP);
|
||||||
bRet = FALSE;
|
bRet = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+41
-41
@@ -1,4 +1,4 @@
|
|||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
#include <vcl.h>
|
#include <vcl.h>
|
||||||
#include <System.Hash.hpp>
|
#include <System.Hash.hpp>
|
||||||
#include <System.IOUtils.hpp>
|
#include <System.IOUtils.hpp>
|
||||||
@@ -88,18 +88,18 @@ DWORD WINAPI GetUrlProc(LPVOID args)
|
|||||||
ZeroMemory(szBuffer, sizeof(szBuffer));
|
ZeroMemory(szBuffer, sizeof(szBuffer));
|
||||||
ZeroMemory(param->dataOut, param->sizeOut);
|
ZeroMemory(param->dataOut, param->sizeOut);
|
||||||
|
|
||||||
// 循环读取缓冲区内容直到结束
|
// 循环读取缓冲区内容直到结束
|
||||||
while( InternetReadFile(param->hRequest, szBuffer, sizeof(szBuffer), &dwByteRead) && dwByteRead > 0){
|
while( InternetReadFile(param->hRequest, szBuffer, sizeof(szBuffer), &dwByteRead) && dwByteRead > 0){
|
||||||
if( pos + dwByteRead > param->sizeOut ){
|
if( pos + dwByteRead > param->sizeOut ){
|
||||||
param->errCode = ERROR_SIZE;
|
param->errCode = ERROR_SIZE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 复制输出数据
|
// 复制输出数据
|
||||||
memcpy( param->dataOut+pos, szBuffer, dwByteRead );
|
memcpy( param->dataOut+pos, szBuffer, dwByteRead );
|
||||||
pos += dwByteRead;
|
pos += dwByteRead;
|
||||||
|
|
||||||
// 清空缓冲区以备下一次读取
|
// 清空缓冲区以备下一次读取
|
||||||
ZeroMemory(szBuffer, sizeof(szBuffer));
|
ZeroMemory(szBuffer, sizeof(szBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,18 +140,18 @@ DWORD WINAPI DownloadProc(LPVOID args)
|
|||||||
|
|
||||||
ZeroMemory(szBuffer, sizeof(szBuffer));
|
ZeroMemory(szBuffer, sizeof(szBuffer));
|
||||||
|
|
||||||
// 循环读取缓冲区内容直到结束
|
// 循环读取缓冲区内容直到结束
|
||||||
while (InternetReadFile(param->hRequest, szBuffer, sizeof(szBuffer), &dwByteRead) && dwByteRead > 0){
|
while (InternetReadFile(param->hRequest, szBuffer, sizeof(szBuffer), &dwByteRead) && dwByteRead > 0){
|
||||||
fwrite( szBuffer, 1, dwByteRead, fp );
|
fwrite( szBuffer, 1, dwByteRead, fp );
|
||||||
|
|
||||||
if( param->hWnd ){
|
if( param->hWnd ){
|
||||||
//显示进度
|
//显示进度
|
||||||
dwReceived += dwByteRead;
|
dwReceived += dwByteRead;
|
||||||
int pos = (int)( dwReceived * 100.0 / dwAllBytes + 0.5 );
|
int pos = (int)( dwReceived * 100.0 / dwAllBytes + 0.5 );
|
||||||
SendMessage( param->hWnd, UM_PROGRESS, 1, pos );
|
SendMessage( param->hWnd, UM_PROGRESS, 1, pos );
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清空缓冲区以备下一次读取
|
// 清空缓冲区以备下一次读取
|
||||||
ZeroMemory(szBuffer, sizeof(szBuffer));
|
ZeroMemory(szBuffer, sizeof(szBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,11 +207,11 @@ void __fastcall TUpgradeThread::Cancel()
|
|||||||
void __fastcall TUpgradeThread::Execute()
|
void __fastcall TUpgradeThread::Execute()
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
//获取列表文件
|
//获取列表文件
|
||||||
//对比文件MD5码=>更新列表
|
//对比文件MD5码=>更新列表
|
||||||
//下载更新列表中的文件
|
//下载更新列表中的文件
|
||||||
if( m_iMode==3 ){
|
if( m_iMode==3 ){
|
||||||
Sleep(1000); //等待app完全退出
|
Sleep(1000); //等待app完全退出
|
||||||
if( UpdateFiles() ){
|
if( UpdateFiles() ){
|
||||||
RegUpdateFlag( 0 );
|
RegUpdateFlag( 0 );
|
||||||
RestartApp();
|
RestartApp();
|
||||||
@@ -222,26 +222,26 @@ void __fastcall TUpgradeThread::Execute()
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
String strText, strProg1, strProg2;
|
String strText, strProg1, strProg2;
|
||||||
//清空目录
|
//清空目录
|
||||||
ClearUpdateDir();
|
ClearUpdateDir();
|
||||||
|
|
||||||
Randomize();
|
Randomize();
|
||||||
|
|
||||||
if( m_hWnd ){
|
if( m_hWnd ){
|
||||||
strText = "正在获取更新列表";
|
strText = "正在获取更新列表";
|
||||||
SendMessage( m_hWnd, UM_SHOWTEXT, 0, (LPARAM)strText.c_str() );
|
SendMessage( m_hWnd, UM_SHOWTEXT, 0, (LPARAM)strText.c_str() );
|
||||||
|
|
||||||
strProg1 = L"——";
|
strProg1 = L"——";
|
||||||
SendMessage( m_hWnd, UM_SHOWTEXT, 1, (LPARAM)strProg1.c_str() );
|
SendMessage( m_hWnd, UM_SHOWTEXT, 1, (LPARAM)strProg1.c_str() );
|
||||||
|
|
||||||
strProg2 = L"正在下载列表文件";
|
strProg2 = L"正在下载列表文件";
|
||||||
SendMessage( m_hWnd, UM_SHOWTEXT, 2, (LPARAM)strProg2.c_str() );
|
SendMessage( m_hWnd, UM_SHOWTEXT, 2, (LPARAM)strProg2.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
String umdfile = GetUpdateMD5File();
|
String umdfile = GetUpdateMD5File();
|
||||||
if( umdfile.Length()>0 && !Terminated ){
|
if( umdfile.Length()>0 && !Terminated ){
|
||||||
if( m_hWnd ){
|
if( m_hWnd ){
|
||||||
strText = "正在检查更新列表";
|
strText = "正在检查更新列表";
|
||||||
SendMessage( m_hWnd, UM_SHOWTEXT, 0, (LPARAM)strText.c_str() );
|
SendMessage( m_hWnd, UM_SHOWTEXT, 0, (LPARAM)strText.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,19 +251,19 @@ void __fastcall TUpgradeThread::Execute()
|
|||||||
int count = ufnLst->Count;
|
int count = ufnLst->Count;
|
||||||
if( count > 0 ){
|
if( count > 0 ){
|
||||||
if( m_hWnd ){
|
if( m_hWnd ){
|
||||||
strText = "正在下载更新文件";
|
strText = "正在下载更新文件";
|
||||||
SendMessage( m_hWnd, UM_SHOWTEXT, 0, (LPARAM)strText.c_str() );
|
SendMessage( m_hWnd, UM_SHOWTEXT, 0, (LPARAM)strText.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( int i=0; i<count && !Terminated; i++ ){
|
for( int i=0; i<count && !Terminated; i++ ){
|
||||||
if( m_hWnd ){
|
if( m_hWnd ){
|
||||||
strProg1 = L"文件数 " + IntToStr( i ) + L"/" + IntToStr( count );
|
strProg1 = L"文件数 " + IntToStr( i ) + L"/" + IntToStr( count );
|
||||||
SendMessage( m_hWnd, UM_SHOWTEXT, 1, (LPARAM)strProg1.c_str() );
|
SendMessage( m_hWnd, UM_SHOWTEXT, 1, (LPARAM)strProg1.c_str() );
|
||||||
|
|
||||||
int pos = (int)( i*100.0/count + 0.5 );
|
int pos = (int)( i*100.0/count + 0.5 );
|
||||||
SendMessage( m_hWnd, UM_PROGRESS, 0, pos );
|
SendMessage( m_hWnd, UM_PROGRESS, 0, pos );
|
||||||
|
|
||||||
strProg2 = L"当前下载文件 " + (*ufnLst)[i];
|
strProg2 = L"当前下载文件 " + (*ufnLst)[i];
|
||||||
SendMessage( m_hWnd, UM_SHOWTEXT, 2, (LPARAM)strProg2.c_str() );
|
SendMessage( m_hWnd, UM_SHOWTEXT, 2, (LPARAM)strProg2.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,7 +298,7 @@ void __fastcall TUpgradeThread::Execute()
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if( m_hWnd ){
|
if( m_hWnd ){
|
||||||
strText = "未发现需要更新的文件";
|
strText = "未发现需要更新的文件";
|
||||||
SendMessage( m_hWnd, UM_SHOWTEXT, 0, (LPARAM)strText.c_str() );
|
SendMessage( m_hWnd, UM_SHOWTEXT, 0, (LPARAM)strText.c_str() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -320,7 +320,7 @@ bool __fastcall TUpgradeThread::MakeMD5File()
|
|||||||
String strText, strProg1, strProg2;
|
String strText, strProg1, strProg2;
|
||||||
|
|
||||||
if( m_hWnd ){
|
if( m_hWnd ){
|
||||||
strText = "正在生成MD5校验文件";
|
strText = "正在生成MD5校验文件";
|
||||||
SendMessage( m_hWnd, UM_SHOWTEXT, 0, (LPARAM)strText.c_str() );
|
SendMessage( m_hWnd, UM_SHOWTEXT, 0, (LPARAM)strText.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,14 +333,14 @@ bool __fastcall TUpgradeThread::MakeMD5File()
|
|||||||
if( fp ){
|
if( fp ){
|
||||||
for( int i=0; i<m_lstFile->Count && !Terminated; i++ ){
|
for( int i=0; i<m_lstFile->Count && !Terminated; i++ ){
|
||||||
if( m_hWnd ){
|
if( m_hWnd ){
|
||||||
strProg1 = L"文件数 " + IntToStr( i )
|
strProg1 = L"文件数 " + IntToStr( i )
|
||||||
+ L"/" + IntToStr( m_lstFile->Count );
|
+ L"/" + IntToStr( m_lstFile->Count );
|
||||||
SendMessage( m_hWnd, UM_SHOWTEXT, 1, (LPARAM)strProg1.c_str() );
|
SendMessage( m_hWnd, UM_SHOWTEXT, 1, (LPARAM)strProg1.c_str() );
|
||||||
|
|
||||||
int pos = (int)( i*100.0/m_lstFile->Count + 0.5 );
|
int pos = (int)( i*100.0/m_lstFile->Count + 0.5 );
|
||||||
SendMessage( m_hWnd, UM_PROGRESS, 0, pos );
|
SendMessage( m_hWnd, UM_PROGRESS, 0, pos );
|
||||||
|
|
||||||
strProg2 = L"当前文件 " + (*m_lstFile)[i];
|
strProg2 = L"当前文件 " + (*m_lstFile)[i];
|
||||||
SendMessage( m_hWnd, UM_SHOWTEXT, 2, (LPARAM)strProg2.c_str() );
|
SendMessage( m_hWnd, UM_SHOWTEXT, 2, (LPARAM)strProg2.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -391,7 +391,7 @@ bool __fastcall TUpgradeThread::GenerateFileMD5( String fname, String& md5 )
|
|||||||
pMD5->Update( buf, sizeBuf );
|
pMD5->Update( buf, sizeBuf );
|
||||||
|
|
||||||
if( m_hWnd ){
|
if( m_hWnd ){
|
||||||
//显示进度
|
//显示进度
|
||||||
int pos = (int)( fs->Position * 100.0 / fs->Size + 0.5 );
|
int pos = (int)( fs->Position * 100.0 / fs->Size + 0.5 );
|
||||||
SendMessage( m_hWnd, UM_PROGRESS, 1, pos );
|
SendMessage( m_hWnd, UM_PROGRESS, 1, pos );
|
||||||
}
|
}
|
||||||
@@ -422,7 +422,7 @@ int __fastcall TUpgradeThread::DownloadFile( String url, String filename )
|
|||||||
|
|
||||||
path += filename;
|
path += filename;
|
||||||
|
|
||||||
for( int i=0; i<3; i++ ){ //尝试3次
|
for( int i=0; i<3; i++ ){ //尝试3次
|
||||||
TDownloadParam param;
|
TDownloadParam param;
|
||||||
param.hWnd = m_hWnd;
|
param.hWnd = m_hWnd;
|
||||||
strcpy( param.url, ((AnsiString)url).c_str() );
|
strcpy( param.url, ((AnsiString)url).c_str() );
|
||||||
@@ -442,9 +442,9 @@ int __fastcall TUpgradeThread::DownloadFile( String url, String filename )
|
|||||||
WaitForSingleObject( hThread, 200 );
|
WaitForSingleObject( hThread, 200 );
|
||||||
CloseHandle( hThread );
|
CloseHandle( hThread );
|
||||||
|
|
||||||
if( dwRet==WAIT_OBJECT_0 ) //用户退出
|
if( dwRet==WAIT_OBJECT_0 ) //用户退出
|
||||||
break;
|
break;
|
||||||
else if( dwRet==WAIT_OBJECT_0+1 ){ //线程正常退出
|
else if( dwRet==WAIT_OBJECT_0+1 ){ //线程正常退出
|
||||||
if( param.errCode==0 ){
|
if( param.errCode==0 ){
|
||||||
ret = 0;
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
@@ -511,7 +511,7 @@ int __fastcall TUpgradeThread::GetServers( TStringList* pList )
|
|||||||
// bool bSave = false;
|
// bool bSave = false;
|
||||||
FILE* fp = NULL;
|
FILE* fp = NULL;
|
||||||
|
|
||||||
//读取文件配置
|
//读取文件配置
|
||||||
fp = fopen( ((AnsiString)m_GlobalFile).c_str(), "rb" );
|
fp = fopen( ((AnsiString)m_GlobalFile).c_str(), "rb" );
|
||||||
if( fp ){
|
if( fp ){
|
||||||
TGVFHEADER header;
|
TGVFHEADER header;
|
||||||
@@ -586,9 +586,9 @@ String __fastcall TUpgradeThread::GetUpdateURL()
|
|||||||
WaitForSingleObject( hThread, 200 );
|
WaitForSingleObject( hThread, 200 );
|
||||||
CloseHandle( hThread );
|
CloseHandle( hThread );
|
||||||
|
|
||||||
if( dwRet==WAIT_OBJECT_0 ) //用户退出
|
if( dwRet==WAIT_OBJECT_0 ) //用户退出
|
||||||
break;
|
break;
|
||||||
else if( dwRet==WAIT_OBJECT_0+1 && param.errCode==0 ){ //线程正常退出
|
else if( dwRet==WAIT_OBJECT_0+1 && param.errCode==0 ){ //线程正常退出
|
||||||
if(dataOut[0]=='\"' && dataOut[param.sizeOut-1]=='\"')
|
if(dataOut[0]=='\"' && dataOut[param.sizeOut-1]=='\"')
|
||||||
dataOut[param.sizeOut-1] = 0;
|
dataOut[param.sizeOut-1] = 0;
|
||||||
|
|
||||||
@@ -690,13 +690,13 @@ int __fastcall TUpgradeThread::GetUpdateFileList( String ufile, TStringList* ufn
|
|||||||
int count = ufnLst->Count;
|
int count = ufnLst->Count;
|
||||||
for( int i=ufnLst->Count-1; i>=0; i-- ){
|
for( int i=ufnLst->Count-1; i>=0; i-- ){
|
||||||
if( m_hWnd ){
|
if( m_hWnd ){
|
||||||
strProg1 = L"文件数 " + IntToStr( count-i-1 ) + L"/" + IntToStr(count);
|
strProg1 = L"文件数 " + IntToStr( count-i-1 ) + L"/" + IntToStr(count);
|
||||||
SendMessage( m_hWnd, UM_SHOWTEXT, 1, (LPARAM)strProg1.c_str() );
|
SendMessage( m_hWnd, UM_SHOWTEXT, 1, (LPARAM)strProg1.c_str() );
|
||||||
|
|
||||||
int pos = (int)( (count-i-1)*100.0/count + 0.5 );
|
int pos = (int)( (count-i-1)*100.0/count + 0.5 );
|
||||||
SendMessage( m_hWnd, UM_PROGRESS, 0, pos );
|
SendMessage( m_hWnd, UM_PROGRESS, 0, pos );
|
||||||
|
|
||||||
strProg2 = L"当前比对文件 " + (*ufnLst)[i];
|
strProg2 = L"当前比对文件 " + (*ufnLst)[i];
|
||||||
SendMessage( m_hWnd, UM_SHOWTEXT, 2, (LPARAM)strProg2.c_str() );
|
SendMessage( m_hWnd, UM_SHOWTEXT, 2, (LPARAM)strProg2.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -788,10 +788,10 @@ bool __fastcall TUpgradeThread::UpdateFiles()
|
|||||||
int iAttr = 0;
|
int iAttr = 0;
|
||||||
String strPath = m_AppPath + L"upgrade\\";
|
String strPath = m_AppPath + L"upgrade\\";
|
||||||
|
|
||||||
//先关闭主程序
|
//先关闭主程序
|
||||||
StopApp();
|
StopApp();
|
||||||
|
|
||||||
Sleep(1000); //等待app完全退出
|
Sleep(1000); //等待app完全退出
|
||||||
|
|
||||||
if( FindFirst(strPath + L"*.*", iAttr, sr)==0 ){
|
if( FindFirst(strPath + L"*.*", iAttr, sr)==0 ){
|
||||||
do{
|
do{
|
||||||
@@ -816,7 +816,7 @@ bool __fastcall TUpgradeThread::UpdateFiles()
|
|||||||
|
|
||||||
int __fastcall TUpgradeThread::RestartApp()
|
int __fastcall TUpgradeThread::RestartApp()
|
||||||
{
|
{
|
||||||
//启动主程序
|
//启动主程序
|
||||||
HANDLE hToken = NULL,
|
HANDLE hToken = NULL,
|
||||||
hTokenDup = NULL;
|
hTokenDup = NULL;
|
||||||
if(OpenProcessToken(GetCurrentProcess(),TOKEN_ALL_ACCESS,&hToken)){
|
if(OpenProcessToken(GetCurrentProcess(),TOKEN_ALL_ACCESS,&hToken)){
|
||||||
@@ -847,31 +847,31 @@ int __fastcall TUpgradeThread::RestartApp()
|
|||||||
|
|
||||||
bool __fastcall TUpgradeThread::StopApp()
|
bool __fastcall TUpgradeThread::StopApp()
|
||||||
{
|
{
|
||||||
HANDLE hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS,0 ); //获取进程快照
|
HANDLE hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS,0 ); //获取进程快照
|
||||||
if( hSnapshot ){
|
if( hSnapshot ){
|
||||||
DWORD idProcess = 0;
|
DWORD idProcess = 0;
|
||||||
PROCESSENTRY32 pe32;
|
PROCESSENTRY32 pe32;
|
||||||
pe32.dwSize = sizeof( PROCESSENTRY32 );
|
pe32.dwSize = sizeof( PROCESSENTRY32 );
|
||||||
|
|
||||||
if(!Process32First( hSnapshot, &pe32 )){ //指向第一个进程
|
if(!Process32First( hSnapshot, &pe32 )){ //指向第一个进程
|
||||||
CloseHandle(hSnapshot);
|
CloseHandle(hSnapshot);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
do{
|
do{
|
||||||
if( lstrcmpi( pe32.szExeFile, MAIN_APP_NAME.c_str() )==0 ){ //查找进程
|
if( lstrcmpi( pe32.szExeFile, MAIN_APP_NAME.c_str() )==0 ){ //查找进程
|
||||||
if( SameModulePath( pe32.th32ProcessID )){
|
if( SameModulePath( pe32.th32ProcessID )){
|
||||||
idProcess = pe32.th32ProcessID;
|
idProcess = pe32.th32ProcessID;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while( Process32Next(hSnapshot, &pe32) ); // 循环直到取不到进程
|
while( Process32Next(hSnapshot, &pe32) ); // 循环直到取不到进程
|
||||||
|
|
||||||
if( idProcess ){
|
if( idProcess ){
|
||||||
HANDLE hApp= OpenProcess( PROCESS_ALL_ACCESS, FALSE, idProcess ); //根据进程ID获取程序的句柄
|
HANDLE hApp= OpenProcess( PROCESS_ALL_ACCESS, FALSE, idProcess ); //根据进程ID获取程序的句柄
|
||||||
if( hApp ){
|
if( hApp ){
|
||||||
if( WaitForSingleObject( hApp, 2000 )==WAIT_TIMEOUT )// 等待程序关闭2秒
|
if( WaitForSingleObject( hApp, 2000 )==WAIT_TIMEOUT )// 等待程序关闭2秒
|
||||||
TerminateProcess( hApp, 0 );
|
TerminateProcess( hApp, 0 );
|
||||||
|
|
||||||
CloseHandle( hApp );
|
CloseHandle( hApp );
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifndef UpgradeThreadH
|
#ifndef UpgradeThreadH
|
||||||
#define UpgradeThreadH
|
#define UpgradeThreadH
|
||||||
@@ -27,7 +27,7 @@ private:
|
|||||||
HWND m_hWnd;
|
HWND m_hWnd;
|
||||||
HANDLE m_hSema;
|
HANDLE m_hSema;
|
||||||
TStringList* m_lstMD5;
|
TStringList* m_lstMD5;
|
||||||
bool m_bUpdateSelf; //ÊÇ·ñ¸üÐÂ×ÔÉí
|
bool m_bUpdateSelf; //是否更新自身
|
||||||
String m_AppPath,
|
String m_AppPath,
|
||||||
m_PathName,
|
m_PathName,
|
||||||
m_Server,
|
m_Server,
|
||||||
|
|||||||
+9
-9
@@ -1,4 +1,4 @@
|
|||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
#include <vcl.h>
|
#include <vcl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -44,10 +44,10 @@ void __fastcall TUpgradeForm::FormDestroy(TObject *Sender)
|
|||||||
void __fastcall TUpgradeForm::FormCloseQuery(TObject *Sender, bool &CanClose)
|
void __fastcall TUpgradeForm::FormCloseQuery(TObject *Sender, bool &CanClose)
|
||||||
{
|
{
|
||||||
if( m_pThread ){
|
if( m_pThread ){
|
||||||
String msg = m_iMode==1 ? L"正在处理中,确认退出程序?"
|
String msg = m_iMode==1 ? L"正在处理中,确认退出程序?"
|
||||||
: L"正在升级中,是否确定中止?";
|
: L"正在升级中,是否确定中止?";
|
||||||
|
|
||||||
int mrRet = MessageBox(Handle, msg.c_str(), L"退出",
|
int mrRet = MessageBox(Handle, msg.c_str(), L"退出",
|
||||||
MB_ICONQUESTION | MB_YESNO);;
|
MB_ICONQUESTION | MB_YESNO);;
|
||||||
|
|
||||||
if( mrRet==mrNo )
|
if( mrRet==mrNo )
|
||||||
@@ -58,8 +58,8 @@ void __fastcall TUpgradeForm::FormCloseQuery(TObject *Sender, bool &CanClose)
|
|||||||
|
|
||||||
void __fastcall TUpgradeForm::FormShow(TObject *Sender)
|
void __fastcall TUpgradeForm::FormShow(TObject *Sender)
|
||||||
{
|
{
|
||||||
Caption = m_iMode==0 ? L"自动升级程序"
|
Caption = m_iMode==0 ? L"自动升级程序"
|
||||||
: L"MD5生成程序";
|
: L"MD5生成程序";
|
||||||
|
|
||||||
m_pThread = new TUpgradeThread(true, m_iMode, m_idSoft, m_sVar, Handle );
|
m_pThread = new TUpgradeThread(true, m_iMode, m_idSoft, m_sVar, Handle );
|
||||||
m_pThread->Start();
|
m_pThread->Start();
|
||||||
@@ -102,13 +102,13 @@ void __fastcall TUpgradeForm::UMComplete(TMessage &msg)
|
|||||||
|
|
||||||
if( m_iMode==0 ){
|
if( m_iMode==0 ){
|
||||||
if( msg.WParam!=0 )
|
if( msg.WParam!=0 )
|
||||||
ShowMessage( "本次更新未能完成" );
|
ShowMessage( "本次更新未能完成" );
|
||||||
}
|
}
|
||||||
else if( m_iMode==1 ){
|
else if( m_iMode==1 ){
|
||||||
if( msg.WParam==0 )
|
if( msg.WParam==0 )
|
||||||
ShowMessage( "处理完毕" );
|
ShowMessage( "处理完毕" );
|
||||||
else
|
else
|
||||||
ShowMessage( "异常中止" );
|
ShowMessage( "异常中止" );
|
||||||
}
|
}
|
||||||
|
|
||||||
Close();
|
Close();
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifndef UpgradeUnitH
|
#ifndef UpgradeUnitH
|
||||||
#define UpgradeUnitH
|
#define UpgradeUnitH
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
#include <Vcl.Forms.hpp>
|
#include <Vcl.Forms.hpp>
|
||||||
#include <Vcl.ComCtrls.hpp>
|
#include <Vcl.ComCtrls.hpp>
|
||||||
|
|
||||||
#define APPNAME "APP×Ô¶¯Éý¼¶³ÌÐò\0"
|
#define APPNAME "APP自动升级程序\0"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
class TUpgradeForm : public TForm
|
class TUpgradeForm : public TForm
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 9.4 KiB |
Reference in New Issue
Block a user