📄 victest.c
字号:
#include <windows.h>
#include <stdio.h>
#include "resource.h"
#include "TVicHW32.h"
// functions declaration
int WINAPI WinMain(HINSTANCE , HINSTANCE , LPSTR, int);
LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK MainDialogProc(HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK AboutDialogProc(HWND, UINT, WPARAM, LPARAM);
void ShowButtons(HWND hDlg);
HANDLE hInst;
HWND hDlgMain = NULL;
DLGPROC lpAbtProc;
char AppName[] = "TVicHW32.DLL 3.0 Test"; // Name of application
DWORD Flag_Intr = 0;
void* PointPhys = NULL;
DWORD PhysAddr = 0;
DWORD IRQCounter;
WORD CurrIRQNumber = 10;
PVicHW32Descriptor HwCtrl;
BOOL ActiveHW = FALSE;
BYTE membuffer[256];
HFONT hFontMemdump = 0;
UINT TimerID = 0;
DWORD Ticks = 0;
WORD nLPT;
int Scan_Code,Data_Reg,Status_Reg;
//----------------------------------------------------------------------------
DWORD
HexToInt(char* s)
{
char hexch[] = "0123456789ABCDEF";
int i,j;
DWORD r,n,k;
char ch;
k=1; r=0;
for (i=strlen(s); i>0; i--) {
ch = s[i-1]; if (ch > 0x3f) ch &= 0xDF;
n = 0;
for (j = 0; j<16; j++)
if (ch == hexch[j])
n = j;
r += (n*k);
k *= 16;
}
return r;
}
//----------------------------------------------------------------------------
char*
PrintMemLine(char *szBuf, LPSTR mem, int len, int dwid, DWORD olbl)
{
int i, j;
BYTE c;
BYTE buff[80];
BYTE tbuf[80];
if (len > dwid)
len = dwid;
*szBuf = 0;
// memory address
sprintf((char *)tbuf, "%08X ", olbl);
strcpy(szBuf, (char *)tbuf);
for (i = 0; i < len; i++) {
c = *mem++;
sprintf((char *)tbuf, "%02X", c);
strcat(szBuf, (char *)tbuf);
if (c >= 32 && c < 127)
buff[i] = c;
else
buff[i] = 46;
}
j = dwid - i;
buff[i] = 0;
for (i = j; i > 0; i--)
strcat(szBuf, " ");
// add ASCII codes.
sprintf((char *)tbuf, " %s", (char *)buff); // " |%s|"
strcat(szBuf, (char *)tbuf);
for (i = j; i > 0; i--)
strcat(szBuf, " ");
return(szBuf);
}
// ---------------------------------------------------------
// Hardware Interrupt Handler
// ---------------------------------------------------------
void _stdcall
HWCtrlHwInterrupt(long HWCounter,
short LPT_DataReg,
short LPT_StatusReg,
short Keyb_ScanCode)
{
Flag_Intr ++;
IRQCounter = HWCounter;
Scan_Code = Keyb_ScanCode;
Data_Reg = LPT_DataReg;
Status_Reg = LPT_StatusReg;
}
//----------------------------------------------------------------------------
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpszCmdLine, int nCmdShow)
{
MSG msg;
HWND hWnd;
WNDCLASS wc;
DLGPROC lpfn;
hInst = hInstance;
wc.style = 0;
wc.lpfnWndProc = MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon (hInstance, MAKEINTRESOURCE(IDI_APPICON));
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground= (HBRUSH)COLOR_BACKGROUND;
wc.lpszMenuName = NULL;
wc.lpszClassName= "VictestWClass";
if (!RegisterClass(&wc))
return FALSE;
hWnd = CreateWindow(
"VictestWClass",
AppName,
WS_OVERLAPPEDWINDOW|WS_CAPTION|WS_MINIMIZEBOX|WS_SYSMENU,
CW_USEDEFAULT,
CW_USEDEFAULT,//0,
CW_USEDEFAULT,//0,
CW_USEDEFAULT,//0,
NULL,
NULL,
hInstance,
NULL);
lpfn = MakeProcInstance(MainDialogProc, hInst);
hDlgMain = (HWND)CreateDialog(hInst, (LPCSTR)MAKEINTRESOURCE(IDD_MAINDIALOG), hWnd, lpfn);
ShowWindow(hWnd, nCmdShow);
ShowWindow(hDlgMain, SW_SHOW);
while(GetMessage (&msg, NULL, 0, 0)) {
if(hDlgMain == NULL || !IsDialogMessage(hDlgMain,&msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (msg.wParam);
}
//----------------------------------------------------------------------------
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
case WM_CREATE:
break;
case WM_COMMAND:
return (DefWindowProc(hWnd, msg, wParam, lParam));
case WM_SETFOCUS:
SetFocus(hDlgMain);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return (DefWindowProc(hWnd, msg, wParam, lParam));
}
return (0);
}
//----------------------------------------------------------------------------
BOOL CALLBACK MainDialogProc(HWND hDlg, UINT message,
WPARAM wParam, LPARAM lParam)
{
RECT rect;
char buffer[256];
int i,Id;
WORD a;
BYTE d;
int nPin;
switch (message) {
case WM_INITDIALOG:
GetWindowRect(hDlg, &rect);
// center and resize window
SetWindowPos( GetParent(hDlg),
NULL,
(GetSystemMetrics(SM_CXSCREEN)-(rect.right-rect.left)) >> 1, // left
(GetSystemMetrics(SM_CYSCREEN)-(rect.bottom-rect.top + GetSystemMetrics(SM_CYCAPTION))) >>1, // top
rect.right-rect.left, // width
rect.bottom-rect.top + GetSystemMetrics(SM_CYCAPTION), // height
SWP_NOZORDER);
CheckDlgButton(hDlg,IDC_HARD,1);
if ((GetVersion() & 0x80000000) != 0)
SetDlgItemText(hDlg, IDE_SOTYPE, "Windows 95/98");
else
SetDlgItemText(hDlg, IDE_SOTYPE, "Windows NT");
SendDlgItemMessage(hDlg, IDE_ADDR01, EM_LIMITTEXT, 4, 0L);
SendDlgItemMessage(hDlg, IDE_ADDR02, EM_LIMITTEXT, 4, 0L);
SendDlgItemMessage(hDlg, IDE_ADDR03, EM_LIMITTEXT, 4, 0L);
SendDlgItemMessage(hDlg, IDE_ADDR04, EM_LIMITTEXT, 4, 0L);
SendDlgItemMessage(hDlg, IDE_DATA01, EM_LIMITTEXT, 2, 0L);
SendDlgItemMessage(hDlg, IDE_DATA02, EM_LIMITTEXT, 2, 0L);
SendDlgItemMessage(hDlg, IDE_DATA03, EM_LIMITTEXT, 2, 0L);
SendDlgItemMessage(hDlg, IDE_DATA04, EM_LIMITTEXT, 2, 0L);
// set defalut data
SetDlgItemInt(hDlg, IDE_ADDR01, 300, FALSE);
SetDlgItemInt(hDlg, IDE_ADDR02, 300, FALSE);
SetDlgItemInt(hDlg, IDE_ADDR03, 300, FALSE);
SetDlgItemInt(hDlg, IDE_ADDR04, 300, FALSE);
SetDlgItemInt(hDlg, IDE_DATA01, 0, FALSE);
SetDlgItemInt(hDlg, IDE_DATA02, 0, FALSE);
SetDlgItemInt(hDlg, IDE_DATA03, 0, FALSE);
SetDlgItemInt(hDlg, IDE_DATA04, 0, FALSE);
SetDlgItemInt(hDlg, IDE_IRQNUMBER, CurrIRQNumber, FALSE);
SendDlgItemMessage(hDlg, IDE_IRQNUMBER, EM_LIMITTEXT, 3, 0L);
PhysAddr = 0xc0044;
sprintf(buffer, "%08X", PhysAddr);
SetDlgItemText(hDlg, IDE_MEMADDR, buffer);
SetDlgItemText(hDlg, IDE_MEMADDR2, "????????");
hFontMemdump = CreateFont(-12, 0, 0, 0, FW_NORMAL,
0, 0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY, FIXED_PITCH | FF_DONTCARE, "Courier New");
SendDlgItemMessage(hDlg, IDL_MEMDUMP, WM_SETFONT, (WPARAM)hFontMemdump, 0L);
SendDlgItemMessage(hDlg, IDE_MEMADDR, WM_SETFONT, (WPARAM)hFontMemdump, 0L);
SendDlgItemMessage(hDlg, IDE_MEMADDR2,WM_SETFONT, (WPARAM)hFontMemdump, 0L);
TimerID = SetTimer(hDlg, 1000, 100, NULL);
SetDlgItemInt(hDlg, IDE_IRQCOUNT , 0, FALSE);
SetDlgItemInt(hDlg, IDE_IRQHANDLED, 0, FALSE);
SetDlgItemInt(hDlg, IDE_IRQTIME , 0, FALSE);
SetDlgItemText(hDlg, IDC_LPTS, "0");
SetDlgItemText(hDlg, IDC_LPT_NUMBER, "0");
SetDlgItemText(hDlg, IDC_BASE, "000h");
ShowButtons(hDlg);
return(TRUE);
case WM_CLOSE:
DestroyWindow(hDlg);
hDlgMain = NULL;
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -