// Q. why i need the new feature (e.g. Configure view log tool from notepad to editplus)
// A. - Mainly for performance reason. Now the tool will creat daily YYYYMMDD.TXT log file realtime, and sometime the log file is bigger than 10M. when we click log view button (default notepad launched now), it will take a long time to open it. if i open the log file folder from the windows explorer with Editplus, it is very fast:-)
Another reason, the tool will be realeased to another lab group user. There is no Editplus in their OS. Based on this condition, i plan to develop the new function still support open the Log file via Notepad defaultly.
// i just tried to take use ShellExecute()... and i will try to learn CreateProcess Function (Windows) too. :-)
-----------------------------------------------------
Menu Click To Configuration.
I just try to save the Editplus Folder Path to a config.ini file.
Code:
void CSECS_AMECDlg::OnMenuConfigviewlog()
{
// TODO: add user configuration for view log edit tool selection
// m_ViewLogDlg.MoveWindow(100, 100, 300, 300);
CFileDialog m_ViewLogDlg(
TRUE,
"exe",
NULL,
OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_NOREADONLYRETURN,
"Exe files (*.exe)|*.exe||");
// Set initial path
m_ViewLogDlg.m_ofn.lpstrInitialDir = "c:\\Program Files";
// Set title of dialog
m_ViewLogDlg.m_ofn.lpstrTitle = "Like to your favorite view tool . e.g. editplus...";
// Show file open dialog
if (m_ViewLogDlg.DoModal() == IDOK)
// Get selected path name
CString editToolInstallPath = m_ViewLogDlg.GetPathName();
// Save the Path to Config.ini
ofstream SavePath("config.ini ");
SavePath << m_ViewLogDlg.GetPathName();
SavePath.close();
}
-------------------------------------------------------------------------
View Log Button Function.
Code:
void CSECS_AMECDlg::OnBnClickedButtonViewLog()
{
// TODO: Add your control notification handler code here
CString logFilePath(Util::GetModulePath().c_str());
logFilePath += "\\\secslog.txt";
CString EditToolConfigPath;
// debug need
if (EditToolConfigPath == "")
// View Log with Notepad defaultly
{
ShellExecute(NULL,NULL,logFilePath,NULL,NULL,SW_SHOWDEFAULT);
}
else
// View Log With Editplsu, UltraEdit, etc...
// Should be more flexiable, no hardcode - the 3rd part edit tool path should be replaced!
{
// editToolInstallPath = "c:\\Program Files\\EditPlus 3\\editplus.exe";
ShellExecute(NULL,NULL,EditToolConfigPath,logFilePath,NULL,SW_SHOWDEFAULT);
}
}
------------------------------------------------------------------
i tested the top related function, it worked well.
But i still have two problems.
ONE:
I can't save the Edit Tool Name Path to local .INI config file, i don't know why?
TWO:
I creaed a small script to try the C++ IO function.
Why it is Octal(e.g. 0015BD68 ) format record from my config.ini ?
Code:
#include "stdafx.h"
#include "atlstr.h"
#include <iostream>
#include <fstream>
using namespace std;
int main () {
CString NamePath;
NamePath = "C:\\Program\\Editplus 3\\editplus.exe";
ofstream f("config.ini");
f << NamePath;
f.close();
return 0;
}