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

📄 tstio.cpp

📁 这是一本学习 window编程的很好的参考教材
💻 CPP
字号:
#include <stdio.h>
#include <windows.h>
#include <math.h>
#include <conio.h>

typedef bool ( *PFNENABLEPORTS)( WORD port,WORD nPortNum);
typedef bool (*PFNDISABLEPORTS)( WORD port,WORD nPortNum);
typedef bool ( *PFNTEST)();
PFNTEST pFnTest=NULL;
PFNENABLEPORTS pEnablePorts=NULL;
PFNDISABLEPORTS pDisablePorts=NULL;

int main()
{

	HINSTANCE hInst=LoadLibrary("NTPORT.DLL");
	if(hInst==NULL)return FALSE;
	pFnTest=(PFNTEST)GetProcAddress(hInst,TEXT("Test"));
	if(!(pFnTest)())printf("\n Test ports failed!");

	pEnablePorts=(PFNENABLEPORTS)GetProcAddress(hInst,TEXT("EnablePorts"));
	if(pEnablePorts==NULL){
		FreeLibrary(hInst);
		return   FALSE;
	}
	pDisablePorts=(PFNDISABLEPORTS)GetProcAddress(hInst,TEXT("DisablePorts"));
	if(pDisablePorts==NULL){
		FreeLibrary(hInst);
		return   FALSE;
	}
	if((pEnablePorts)(0x40,1)==false)printf("\n Enable ports 40 failed!");
	if((pEnablePorts)(0x43,1)==false)printf("\n Enable ports 43 failed!");;
//Speed your Timer
	printf("现在,你的时钟飞快地闪烁!\n");
	printf("按回车恢复原状!\n");
	__asm {
		mov al,34h
		out 43h,al
		mov ax,0046h
		out 40h,al
		mov al,ah
		out 40h,al
	}
getchar();
//restore your timer
	__asm {
		mov al,34h
		out 43h,al
		mov ax,1770h
		out 40h,al
		mov al,ah
		out 40h,al
	}

	if((pDisablePorts)(0x40,1)==false||(pDisablePorts)(0x43,1)==false)printf("\n Enable ports failed!");
	FreeLibrary(hInst);
	return TRUE;
}

⌨️ 快捷键说明

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