C++代码求解释
#include "stdio.h"
#include "string.h"
#include <windows.h>
#include <conio.h>
#include <iostream.h>
#include <mmsystem.h>
#include <time.h>
#pragma comment(lib, "winmm.lib")
struct CONSOLE_FONT
{
DWORD index;
COORD dim;
};
typedef BOOL (WINAPI *PROCSETCONSOLEFONT)(HANDLE, DWORD);
PROCSETCONSOLEFONT SetConsoleFont;
HANDLE h1=GetStdHandle(STD_OUTPUT_HANDLE);
void gotoXY(int x, int y)//控制光标的位置
{
COORD coord = {x, y};
SetConsoleCursorPosition(h1, coord);
return;
}
int main(int argc, char* argv[])
{
int m=0,i=0,ret=0;
double t;
SYSTEMTIME sys;//系统时间结构体
GetLocalTime(&sys);
t=time(0)+sys.wMilliseconds/1000.0;
HMODULE hKernel32 = GetModuleHandle("kernel32");
SetConsoleFont = (PROCSETCONSOLEFONT)GetProcAddress(hKernel32,"SetConsoleFont");
SetConsoleFont(h1, 1);//控制字体大小
MCI_OPEN_PARMS mciOpen;
mciOpen.lpstrDeviceType = "mpegvideo ";
mciOpen.lpstrElementName = "apple.mp3";
mciSendCommand(0,MCI_OPEN,MCI_OPEN_TYPE | MCI_OPEN_ELEMENT,(DWORD)&mciOpen);
UINT DeviceID=mciOpen.wDeviceID;
MCI_PLAY_PARMS mciPlay;
mciSendCommand(DeviceID,MCI_PLAY,0 ,(DWORD)&mciPlay);
system("mode con cols=101 lines=44");
FILE *read;
read=fopen("apple.txt","r");
char ch;
char chex[13100]={0};
char colors[10]={"color f0"};
system(colors);
while(!feof(read))
{
ch=fgetc(read);
if(chex[m]!=ch)
chex[m]=ch;
m++;
if(chex[m-1]=='k'&& chex[m-2]=='r' &&chex[m-3]=='a' && chex[m-6]=='k' )
{
m=0;
ch=fgetc(read);
gotoXY(0,0);
printf(chex);
while((time(0)+sys.wMilliseconds/1000.0-t<0.032))
{
Sleep(1);
GetLocalTime(&sys);
}
GetLocalTime(&sys);
t=time(0)+sys.wMilliseconds/1000.0;
}
}
getchar();
return 0;
}