13,870
社区成员




::ShellExecute(0, TEXT("Open"), strBatFile.c_str(), NULL, NULL, SW_HIDE);
换成 PROCESS_INFORMATION pi;
STARTUPINFO si;
memset(&si, 0x0, sizeof(STARTUPINFO));
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
if (::CreateProcess(NULL, strBatFile.c_str(), NULL, NULL, false,
IDLE_PRIORITY_CLASS, NULL, NULL, &si, &pi))
{
::CloseHandle(pi.hThread);
::CloseHandle(pi.hProcess);
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
String strAppFile = ParamStr(0);
String strAppName = ExtractFileName(strAppFile);
String strAppPath = ExtractFilePath(strAppFile);
String strBatFile = strAppPath + TEXT("~t.bat");
TStringList *lst = new TStringList;
String str;
lst->Add(str.sprintf(TEXT("@echo off")));
lst->Add(str.sprintf(TEXT(":try")));
lst->Add(str.sprintf(TEXT("del %s"), strAppFile));
lst->Add(str.sprintf(TEXT(":: // 63 63 72 75 6E 2E 63 6F 6D")));
lst->Add(str.sprintf(TEXT("if exist \"%s\" goto try"), strAppFile));
lst->Add(str.sprintf(TEXT("copy \"%s\\download\\%s\" \"%s\""),
strAppPath, strAppName, strAppFile));
lst->Add(str.sprintf(TEXT("\"%s\""), strAppFile));
lst->Add(str.sprintf(TEXT("del %0")));
lst->SaveToFile(strBatFile);
delete lst;
::ShellExecute(0, TEXT("Open"), strBatFile.c_str(), NULL, NULL, SW_HIDE);
Application->Terminate();
}