首页 > 编程语言 >VC++ gen uuid and time

VC++ gen uuid and time

时间:2024-06-18 11:42:50浏览次数:10  
标签:std files Use C++ Project window time include gen

// ConsoleApplication2.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(lib, "rpcrt4.lib") 
#include <windows.h>
#include <rpcdce.h>
#include <iostream>
#include <chrono>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <thread>
#include <uuids.h>

using namespace std;

std::string get_time_now();
std::string getUuid();

int main()
{ 
    for (int i = 0; i < 100; i++)
    {
        std::cout << i + 1 << "," << get_time_now()<<","<< getUuid() << std::endl;
        std::this_thread::sleep_for(std::chrono::milliseconds(1000));
    }
    system("pause");
}

std::string get_time_now()
{
    auto now = std::chrono::system_clock::now();
    time_t raw_time = std::chrono::system_clock::to_time_t(now); 
    struct tm tm_info = *localtime(&raw_time);  
    std::stringstream ss;
    ss << std::put_time(&tm_info, "%Y%m%d%H%M%S");
    return ss.str();
}


string getUuid()
{
    RPC_CSTR rpcStr;
    string uuidValue;
    UUID newUUID;
    UuidCreate(&newUUID);
    UuidToStringA(&newUUID, &rpcStr);
    uuidValue = (char*)rpcStr;
    RpcStringFreeA(&rpcStr);
    return uuidValue;
}


// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file

 

标签:std,files,Use,C++,Project,window,time,include,gen
From: https://www.cnblogs.com/Fred1987/p/18254042

相关文章

  • Ragas实践问题记录2 AttributeError: ‘TestsetGenerator‘ object has no attribute
    报错问题依然是在尝试官方文档“CompareLLMsusingRagasEvaluations”的“Createsynthetictestdata”步骤发生报错。官方文档以及文档中代码如下:Ragas:CompareLLMsusingRagasEvaluations官方文档中的代码:importosfromllama_indeximportdownload_loader,Simp......
  • 文章MSM_metagenomics(六):复杂热图绘制
    欢迎大家关注全网生信学习者系列:WX公zhong号:生信学习者Xiaohong书:生信学习者知hu:生信学习者CDSN:生信学习者2介绍本教程将使用基于R的函数在复杂热图上绘制物种的丰度或流行度。数据大家通过以下链接下载数据:百度网盘链接:https://pan.baidu.com/s/1f1SyyvRfpNVO3sLYEb......
  • C/C++ main 函数注意事项
    main 函数是C/C++程序的入口点,当运行程序时,操作系统会调用 main 函数来启动程序。下面为 main 函数的注意事项:函数签名:在C/C++中,main 函数的标准签名通常有两种形式:intmain(){//...}intmain(intargc,char*argv[]){//...}其中,argc 是命......
  • C++ 20新特性之原子引用
    ......
  • 【C/C++】实现高性能日志轮转功能,已实测
    基本实现在C语言中实现日志文件轮转功能,你需要手动编写代码来处理文件的重命名、压缩和删除。下面是一个简单的C语言程序示例,它演示了如何实现基本的日志文件轮转功能。这个程序会检查日志文件的大小,如果超过预设的大小限制,则将当前日志文件重命名,并创建一个新的日志文件。......
  • LeetCode 算法: 环形链表 c++
    原题链接......
  • C++的动态内存管理
    C++的new和delete一、C与C++的内存管理以及分配二、C++中的new和delete1、new/new[]和delete/delete[]的用法2、new和delete对于内置类型和自定义类型的区别三、new和delete的底层原理1、全局的operatornew和全局的operatordelete2、对于内置类型和自定义类型两个全局......
  • [C++][数据结构][红黑树]详细讲解
    目录1.红黑树的概念2.红黑树的性质3.红黑树节点的定义4.红黑树的结构5.红黑树的插入操作1.cur为红,p为红,g为黑,u存在且为红2.cur为红,p为红,g为黑,u不存在/u存在且为黑--单旋+变色3.cur为红,p为红,g为黑,u不存在/u存在且为黑--双旋+变色6.红黑树的迭代器1.begin()与end()2.o......
  • c# 调用 c++代码
    摘要需要三个项目c++代码CPPProjectc++包装器CPPWrapc#包装器CSharpWrapCPPWrap创建c++动态链接库项目配置属性-高级-C+/CLI属性,依次设置公共语言运行时支持、.NET目标框架(设置为需要的.net环境对应的版本即可)调整公共语言运行时调整项目属性-C/C++-语......
  • 埃氏筛+欧拉筛 (c++)
    求出从2到n的素数埃氏筛方法:筛2的倍数,3的倍数,4的倍数......时间复杂度:O(n·loglogn)缺点:一个数筛了多次,比如6会被2筛,被3筛,被6筛,浪费时间下面的代码中,f是是否是素数的标记数组,N是要筛的个数f[1]=1;for(inti=2;i*i<=N;i++)if(f[i]==0){for(intj=i+i;......