⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vm_trace_log_win32.c

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 C
字号:
/*////                  INTEL CORPORATION PROPRIETARY INFORMATION//     This software is supplied under the terms of a license agreement or//     nondisclosure agreement with Intel Corporation and may not be copied//     or disclosed except in accordance with the terms of that agreement.//       Copyright(c) 2003-2005 Intel Corporation. All Rights Reserved.//*/#include <stdio.h>#include <stdarg.h>#include "vm_trace_log.h"#if defined(_WIN32) || defined(_WIN64) || defined(_WIN32_WCE)void vm_trace_log(vm_trace_atribute atr, vm_char *line){    SYSTEMTIME SystemTime;    MEMORYSTATUS stat;    vm_char tmp[1024] = {0,};    vm_char tmp1[1024] = {0,};    GlobalMemoryStatus(&stat);    GetLocalTime(&SystemTime);    /* print date */    if ((WITHDATE == atr) || (WITHALL == atr))    {        vm_string_sprintf(tmp,                          __VM_STRING("%s%.2d.%.2d.%.4d,"),                          tmp,                          SystemTime.wDay,                          SystemTime.wMonth,                          SystemTime.wYear);    }    /* print time */    if ((WITHTIME == atr) || (WITHALL == atr))    {        vm_string_sprintf(tmp,                          __VM_STRING("%s%.2d:%.2d:%.2d,"),                          tmp,                          SystemTime.wHour,                          SystemTime.wMinute,                          SystemTime.wSecond);    }    /* print memory */    if ((WITHMEM == atr) || (WITHALL == atr))    {        vm_string_sprintf(tmp,                          __VM_STRING("%s%d,"),                          tmp,                          (stat.dwTotalPageFile - stat.dwAvailPageFile) / (1024 * 1024));    }    vm_string_sprintf(tmp1, __VM_STRING("%s"), line);    vm_string_sprintf(line, __VM_STRING("%s%s\n"), tmp, tmp1);} /* void vm_trace_log(vm_trace_atribute atr, vm_char *line) */void* vm_open_logfile(vm_char *log_file, vm_char *file_ini, vm_char *dir){    HKEY hKey;    vm_char exe_path[256] = {0,};    vm_char exe_name[256] = {0,};    vm_char buf[256] = {0,};    vm_char tmp[256];    vm_sizet sizet = 256;    SYSTEMTIME SystemTime;    vm_char comp_name[256];    FILE *pFile = NULL;    int i, ch = ' ', k = 0;    memset(tmp, 0, sizeof(tmp));    GetModuleFileName(NULL, tmp, _MAX_PATH);    i = (int) (vm_string_strrchr(tmp, (vm_char)('\\')) - tmp + 1);    vm_string_strncpy(exe_path, tmp, i - 1);    vm_string_strncpy(exe_name, tmp + i, vm_string_strlen(tmp) - i);    vm_string_sprintf(tmp, __VM_STRING("%s\\%s"), exe_path, file_ini);    vm_string_sprintf(file_ini, tmp);    pFile = vm_file_open(tmp, __VM_STRING("r"));    memset(tmp, 0, sizeof(tmp));    if (pFile)    {        while (_TEOF != vm_file_scanf(pFile, __VM_STRING("%s"), buf))        {            if (!vm_string_strcmp(buf, __VM_STRING("OUTPUT_LOG_PATH")))            {                vm_file_gets(buf, 256, pFile);                if ('.' == buf[1])                    vm_string_sprintf(tmp, __VM_STRING("%s\\"), exe_path);                vm_string_strncat(tmp, buf + 1, (unsigned int)vm_string_strlen(buf) - 2);            }            else                vm_file_gets(buf, 256, pFile);        }        fclose(pFile);    }    else        vm_string_sprintf(tmp, __VM_STRING("%s\\Logs\\"), exe_path);    if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE,                      __VM_STRING("SYSTEM\\ControlSet001\\Control\\ComputerName\\ActiveComputerName"),                      0,                      KEY_QUERY_VALUE,                      &hKey))    {        k = 0;        sizet = 256;        RegQueryValueEx(hKey,                        __VM_STRING("ComputerName"),                        NULL,                        NULL,                        (LPBYTE)buf,                        (LPDWORD)(&sizet));        while (ch == buf[k++]);        vm_string_strcpy(comp_name, (vm_char *)(buf + k - 1));        /* make sure to close the reg key */        RegCloseKey(hKey);    }    else    {        vm_string_sprintf(comp_name, __VM_STRING("unknown"));        sizet = 7;    }    if (dir)    {        vm_string_sprintf(tmp, __VM_STRING("%s%s\\"), tmp, dir);    }    else    {        if (sizet)            vm_string_sprintf(tmp, __VM_STRING("%s%s\\"), tmp, comp_name);        else            vm_string_sprintf(tmp, __VM_STRING("%sunknown\\"), tmp);    }    memset(buf, 0, sizeof(buf));    for (i = 1;i < (int)vm_string_strlen(tmp);i++)    {        if (('\\' == tmp[i]) && ((':' != tmp[i - 1]) && ('\\' != tmp[i - 1])))        {            vm_string_strncpy(buf, tmp, i);            CreateDirectory(buf, NULL);        }    }    sizet = 256;    GetLocalTime(&SystemTime);    memset(buf, 0, sizeof(buf));    vm_string_strcpy(buf, log_file);    vm_string_sprintf(log_file,                      __VM_STRING("%s%s_%.2d%.2d_%.2d%.2d%.2d%s"),                      tmp,                      comp_name,                      SystemTime.wMonth,                      SystemTime.wDay,                      SystemTime.wHour,                      SystemTime.wMinute,                      SystemTime.wSecond,                      buf);    return vm_file_open(log_file, __VM_STRING("w"));}#endif /* defined(_WIN32) || defined(_WIN64) || defined(_WIN32_WCE) */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -