C++常用
控制台输出命名空间
#include <windows.h>
#include <iostream>
#include <stdio.h>
using namespace std
//控制台打印字符串
char cha[] = "世界你好!";
cout << "字符串地址=:" << &cha<<endl;
#pragma comment(lib,"testDLL.lib")
//NMCHAR https://learn.microsoft.com/zh-cn/windows/win32/controls/subclassing-overview
//常规控件参考 https://learn.microsoft.com/zh-cn/windows/win32/controls/common-control-reference
#pragma warning(disable:4996)**加粗样式**
毫秒级时间计算
#include <stdio.h>
#include <windows.h>
#include <time.h> //time_t time() clock_t clock()
#include <Mmsystem.h> //timeGetTime()
#pragma comment(lib, "Winmm.lib") //timeGetTime()
int main()
{
//用time()来计时 秒
time_t timeBegin, timeEnd;
timeBegin = time(NULL);
Sleep(1000);
timeEnd = time(NULL);
printf("%d\n", timeEnd - timeBegin);
//用clock()来计时 毫秒
clock_t clockBegin, clockEnd;
clockBegin = clock();
Sleep(800);
clockEnd = clock();
printf("%d\n", clockEnd - clockBegin);
//用timeGetTime()来计时 毫秒
DWORD dwBegin, dwEnd;
dwBegin = timeGetTime();
Sleep(800);
dwEnd = timeGetTime();
printf("%d\n", dwEnd - dwBegin);
//用GetTickCount()来计时 毫秒
DWORD dwGTCBegin, dwGTCEnd;
dwGTCBegin = GetTickCount();
Sleep(806);
dwGTCEnd = GetTickCount();
printf("%d\n", dwGTCEnd - dwGTCBegin);
//用QueryPerformanceCounter()来计时 微秒
LARGE_INTEGER large_interger;
double dff;
__int64 c1, c2;
QueryPerformanceFrequency(&large_interger);
dff = large_interger.QuadPart;
QueryPerformanceCounter(&large_interger);
c1 = large_interger.QuadPart;
Sleep(800);
QueryPerformanceCounter(&large_interger);
c2 = large_interger.QuadPart;
printf("本机高精度计时器频率%lf\n", dff);
printf("第一次计时器值%I64d 第二次计时器值%I64d 计时器差%I64d\n", c1, c2, c2 - c1);
printf("计时%lf毫秒\n", (c2 - c1) * 1000 / dff);
printf("By MoreWindows\n");
return 0;
//LARGE_INTEGER start, end;
//LARGE_INTEGER pers;
//QueryPerformanceFrequency(&pers);
//double dff = pers.QuadPart;
//QueryPerformanceCounter(&start);
//Sleep(2805);
//QueryPerformanceCounter(&end);
//hw.Format("%I64f", (end.QuadPart - start.QuadPart) * 1000 / dff);
//SetDlgItemText(EDIT1, hw);
}