void TMainDlg::WriteLogHeader(HANDLE hFile, BOOL add_filelog) { static const char *head_start = "================================================="; static const char *head_end = "-------------------------------------------------"; char buf[1024]; ::SetFilePointer(hFile, 0, 0, FILE_END); DWORD len = sprintf(buf, "%s\r\nFastCopy(%s%s) start at %d/%02d/%02d %02d:%02d:%02d\r\n\r\n", head_start, GetVersionStr(), GetVerAdminStr(), startTm.wYear, startTm.wMonth, startTm.wDay, startTm.wHour, startTm.wMinute, startTm.wSecond); ::WriteFile(hFile, buf, len, &len, 0); if (pathLogBuf) { ::WriteFile(hFile, pathLogBuf, (DWORD)strlen(pathLogBuf), &len, 0); } if (add_filelog && *fileLogPath) { len = sprintf(buf, "<FileLog> %s\r\n", cfg.isUtf8Log ? WtoU8s(fileLogPath) : WtoAs(fileLogPath)); ::WriteFile(hFile, buf, len, &len, 0); } if (finActIdx >= 1) { const WCHAR *title = cfg.finActArray[finActIdx]->title; len = sprintf(buf, "<PostPrc> %s\r\n%s\r\n", cfg.isUtf8Log ? WtoU8s(title) : WtoAs(title), head_end); ::WriteFile(hFile, buf, len, &len, 0); } else if (pathLogBuf || (add_filelog && *fileLogPath)) { len = sprintf(buf, "%s\r\n", head_end); ::WriteFile(hFile, buf, len, &len, 0); } }
/* メインダイアログ用 WM_INITDIALOG 処理ルーチン */ BOOL TInstDlg::EvCreate(LPARAM lParam) { char title[256], title2[256]; GetWindowText(title, sizeof(title)); ::wsprintf(title2, "%s ver%s", title, GetVersionStr()); SetWindowText(title2); GetWindowRect(&rect); int cx = ::GetSystemMetrics(SM_CXFULLSCREEN), cy = ::GetSystemMetrics(SM_CYFULLSCREEN); int xsize = rect.right - rect.left, ysize = rect.bottom - rect.top; ::SetClassLong(hWnd, GCL_HICON, (LONG)::LoadIcon(TApp::GetInstance(), (LPCSTR)SETUP_ICON)); MoveWindow((cx - xsize)/2, (cy - ysize)/2, xsize, ysize, TRUE); Show(); if (IsWinVista() && !::IsUserAnAdmin() && TIsEnableUAC()) { HWND hRunas = GetDlgItem(RUNAS_BUTTON); ::SetWindowLong(hRunas, GWL_STYLE, ::GetWindowLong(hRunas, GWL_STYLE)|WS_VISIBLE); ::SendMessage(hRunas, BCM_SETSHIELD, 0, 1); } // 現在ディレクトリ設定 char buf[MAX_PATH_U8], setupDir[MAX_PATH_U8]; #ifdef _WIN64 char x86dir[MAX_PATH_U8] = ""; #endif // Program Filesのパス取り出し TRegistry reg(HKEY_LOCAL_MACHINE); if (reg.OpenKey(REGSTR_PATH_SETUP)) { if (reg.GetStr(REGSTR_PROGRAMFILES, buf, sizeof(buf))) { MakePath(setupDir, buf, IPMSG_STR); } #ifdef _WIN64 if (reg.GetStr(REGSTR_PROGRAMFILESX86, buf, sizeof(buf))) MakePath(x86dir, buf, IPMSG_STR); #endif reg.CloseKey(); } // 既にセットアップされている場合は、セットアップディレクトリを読み出す if (reg.OpenKey(REGSTR_PATH_APPPATHS)) { if (reg.OpenKey(IPMSG_EXENAME)) { if (reg.GetStr(REGSTR_PATH, buf, sizeof(buf))) { #ifdef _WIN64 if (strcmp(buf, x86dir)) #endif strcpy(setupDir, buf); } reg.CloseKey(); } reg.CloseKey(); } SetDlgItemTextU8(FILE_EDIT, setupDir); CheckDlgButton(STARTUP_CHECK, 1); CheckDlgButton(PROGRAM_CHECK, 1); CheckDlgButton(DESKTOP_CHECK, 1); CheckDlgButton(EXTRACT_CHECK, 0); char *p = strstr(GetCommandLine(), "runas="); if (p) { runasWnd = (HWND)strtoul(p+6, 0, 16); if (!runasWnd || !IsWindow(runasWnd)) PostQuitMessage(0); if ((p = strstr(p, ",imm="))) runasImm = atoi(p+5); CheckDlgButton(EXTRACT_CHECK, ::IsDlgButtonChecked(runasWnd, EXTRACT_CHECK)); CheckDlgButton(STARTUP_CHECK, ::IsDlgButtonChecked(runasWnd, STARTUP_CHECK)); CheckDlgButton(PROGRAM_CHECK, ::IsDlgButtonChecked(runasWnd, PROGRAM_CHECK)); CheckDlgButton(DESKTOP_CHECK, ::IsDlgButtonChecked(runasWnd, DESKTOP_CHECK)); WCHAR wbuf[MAX_PATH] = L""; ::SendDlgItemMessageW(runasWnd, FILE_EDIT, WM_GETTEXT, MAX_PATH, (LPARAM)wbuf); SetDlgItemTextU8(FILE_EDIT, WtoU8s(wbuf)); ::SendMessage(runasWnd, WM_IPMSG_HIDE, 0, 0); if (runasImm) { PostMessage(WM_IPMSG_INSTALL, 0, 0); } } return TRUE; }