实现打印安装过程中的日志到临时目录的文件中。日志文件以年月日为文件名。
static void MakeTempFileName(char* buf, int bufSize)
{
char TempPath[MAX_PATH] = {0};
GetTempPathA(MAX_PATH,TempPath);
StringCbCopyA(buf,bufSize,TempPath);
char TempName[MAX_PATH] = {0};
struct tm *local;
time_t t;
t = time(NULL);
local = localtime(&t);
StringCbPrintfA(TempName,sizeof(TempName),"%d-%d-%d.txt",local->tm_year,local->tm_mon,local->tm_mday);
StringCbCatA(buf,bufSize,TempName);
}
static FILE* fp = NULL;
extern "C" void __declspec(dllexport)
Log(HWND hwndParent,
int string_size,
CHAR *variables,
stack_t **stacktop,
extra_parameters *extra)
{
int iFunctionCode = 0;
BOOL bValue = FALSE;
//插件初始化
g_hwndParent = hwndParent;
EXDLL_INIT();
//获取NSIS脚本传入的参数,检查有效性
char sz[4096] = {0};
memset(sz,0,sizeof(sz));
struct tm *local;
time_t t;
t = time(NULL);
local = localtime(&t);
StringCbCopy